Factor in R
Factor
is a special vector in R. It can be ordered or unordered and are
important when for modeling functions such as lm() and glm() and also in plot methods.
Factors have to be pre-defined values.
#
Empty
Command::
factor()
#Example
spectrum
<- c('Red','green','yellow','Voilet','Cyan','Magenta','Orange')
factor_spectrum<-factor(spectrum)
print(factor_spectrum)
[1]
Red green yellow
Voilet Cyan Magenta Orange
Levels:
Cyan green Magenta Orange Red Voilet yellow
print(nlevels(factor_spectrum))
[1]
7
Factor in R
Reviewed by Rupesh
on
00:17
Rating:
No comments: