[R] Opinion: Why I find factors convenient to use
S Ellison
S.Ellison at LGCGroup.com
Mon Aug 20 13:30:32 CEST 2012
> -----Original Message-----
> Over the years, many people -- including some who I would
> consider real expeRts -- have criticized factors and
> advocated the use (sometimes exclusively) of character
> vectors instead.
Exclusive use of character vectors is not going to do the job.
The concept of a factor is fundamental to a lot of statistics; a programming environment that does not implement factors and their associated special behaviour is probably not a statistical programming language.
Special behaviours I have in mind include:
- Level order can be arbitrarily specified for display purposes
- A control level can be intentionally chosen for contrasts
- the option of "ordered" factors (for example, for polr and the like)
So I think the language does and will require a 'factor' type in one form or another.
_When_ you decide to convert a character input to a factor is, of course, up to the user,and for cleanup it's very often better to stick with character early and convert to factor a bit later. But personally, I think that there is sufficient control over the coding of data to allow user discretion. and on the whole, it seems to me that character input gets used as factor data so much of the time when it is used at all that the default stringsAsFactors=TRUE setting seems the more sensible default.
S Ellison
*******************************************************************
This email and any attachments are confidential. Any use...{{dropped:8}}
More information about the R-help
mailing list