[R] Factor function

Petr PIKAL petr.pikal at precheza.cz
Tue Apr 26 10:51:33 CEST 2011


Hi


d<-data.frame(matrix(c("ww","ww","xx","yy","ww","yy","xx","yy","NA"), 
ncol=3, byrow=TRUE))

Change character value "NA" to missing value <NA>
d[d[,3]=="NA",3]<-NA

If you want drop any unused levels of a factor just use

factor(d[,3])
[1] xx   yy   <NA>
Levels: xx yy

Regards
Petr


r-help-bounces at r-project.org napsal dne 25.04.2011 23:03:15:

> Thank you for your reply again. I really know that NA is not "NA". I 
just
> want to figure out how to remove "NA" from the levels. Thanks again.
> 
> --
> View this message in context: 
http://r.789695.n4.nabble.com/Factor-function-
> tp3473984p3474127.html
> Sent from the R help mailing list archive at Nabble.com.
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list