[R] How to exclude a level from a factor

Qiong Yang qyang at bu.edu
Tue Sep 20 18:59:51 CEST 2005


Hi,

I could not use 'exlcude=' option in factor()
to exclude a level from a existing factor.

x is a factor:

> x
[1] a b c
Levels: a b c

> factor(x,exclude="c")
[1] a b c
Levels: a b c
Warning message:
NAs introduced by coercion

However, "c" is not coded as NA.

The following does not work either:

> factor(x,exclude=factor("c",levels=c("a","b","c")))
[1] a b c
Levels: a b c


What's wrong with my codes?

Thanks for any help

Qiong Yang




More information about the R-help mailing list