Re: [R] Factor function

From: Petr PIKAL <petr.pikal_at_precheza.cz>
Date: Tue, 26 Apr 2011 10:51:33 +0200

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.



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. Received on Tue 26 Apr 2011 - 08:55:40 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 26 Apr 2011 - 17:50:33 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive