[R] When factor is better than other types, such as vector and frame?
p.hiemstra at geo.uu.nl
Sun Aug 23 10:08:42 CEST 2009
Peng Yu schreef:
> It is easy to understand the types vector and frame.
> But I am wondering why the type factor is designed in R. What is the
> advantage of factor compare with other data types in R? Can somebody
> give an example in which case the type factor is much better than
> other data types?
> R-help at r-project.org mailing list
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.Hi,
Factor is better when the variable is categorical, such as 'Forest',
'Woodland' etc. When performing for example an lm() the categorical
variables have to be a factor in order for R to recognize it in that way.
More information about the R-help