That would fall under the category of numerical coding.
In fact, take a look at this piece of R code:
colors <- c("Red", "Green", "Yellow")
colors.df <- data.frame(color=sample(colors, size=25, replace=TRUE))
str(colors.df)
If you run these lines you'll see that R actually internally encodes factors in the very same way you've described. Crazy!
As suggested in the Comments, there is one important caveat, however: Just because you're using numbers to efficiently represent the values of your categorical variable does not mean that you can treat them as numbers. In other words, your data remains categorical regardless of any name changes you may have applied.
Nevertheless, there's nothing inherently wrong with this particular coding scheme. In fact, it's entirely reasonable.
Hope this helps!
SEE ALSO: The numerical coding of information (Swerdlin, 1974)
Clarification:
Today, it seems as though (at least to me) that the concept of coding arises most often in the context of regression (for example, as mentioned in the original post, recoding categorical variables as dummy variables). However, the notion of coding systems is actually much more general than this current usage may suggest, as indicated by its entry in Dover's Outline of Basic Statistics: Dictionary and Formulas:
Coding System - In information theory, any consistent scheme used to represent
a given set of data. A coding system is usually employed either to reduce
error or increase efficiency in the transmission of information.
According to this standard, it is clear that the simple mapping of colors to integers as described in the original post would, indeed, qualify as a coding scheme. Other than merely reducing the size of the data being stored (since, for example, the vector c("Green", "Green", "Yellow", "Red")
could now be stored more compactly as c(2,2,3,1)
), there does not appear to be much benefit to this specific scheme, however. Nevertheless, it still qualifies as a coding system.
Now, to elaborate on the "important caveat" mentioned above (in my original answer), this particular coding scheme is very misleading within the regression setting. In fact, in its entry for "Dummy Variable", the Cambridge Dictionary of Statistics indicates the importance of re-coding (via Dummy Variables) such numerical codes when in the regression setting:
"Such recoding is used before polychotomous variables are used as
explanatory variables in a regression analysis to avoid the unreasonable
assumption that the original numerical codes for the categories, i.e. the
values 1,2,...,k, correspond to an interval scale."
Thus, it's not that this system of coding is meaningless, per se, within the regression setting; rather, the misspecification is due to attributing more meaning to these numerical codes than would otherwise be warranted. Make sense?
Hope this clarifies my original answer!
Red
andYellow
withGreen
. It amounts to a kind of (arbitrary) valuation of the colors. Therefore it does not have any standard name. $\endgroup$