[R] Indexing on a variable that is a factor

Uwe Ligges ligges at statistik.uni-dortmund.de
Sat Sep 9 19:12:11 CEST 2006

Farrel Buchinsky wrote:
> It is easy to index on numeric variables.
> How does one index on a variable that is a factor?

Same as for numeric objects. Example:

R> x <- factor(c("A", "B"))
R> x
[1] A B
Levels: A B

R> x[1]
[1] A
Levels: A B

More information about the R-help mailing list