[R] where are these NAs coming from?

jim holtman jholtman at gmail.com
Wed Sep 19 19:58:08 CEST 2012


At least provide a reproducible example by creating the problem with a
subset of 'z' and 'mycountry'

Could something like this be happening?

> x <- data.frame(country = 1:5, language = 1:5)
> mycountry <- NA
> z <- x[x$country == mycountry,]
> z
     country language
NA        NA       NA
NA.1      NA       NA
NA.2      NA       NA
NA.3      NA       NA
NA.4      NA       NA


On Wed, Sep 19, 2012 at 1:50 PM, Sam Steingold <sds at gnu.org> wrote:
> I see this:
> --8<---------------cut here---------------start------------->8---
>> length(which(is.na(z$language)))
> [1] 0
>> locals <- z[z$country == mycountry,]
>> length(which(is.na(locals$language)))
> [1] 229
> --8<---------------cut here---------------end--------------->8---
> where are those locals without the language coming from?!
>
> --
> Sam Steingold (http://sds.podval.org/) on Ubuntu 12.04 (precise) X 11.0.11103000
> http://www.childpsy.net/ http://ffii.org http://honestreporting.com
> http://camera.org http://www.memritv.org http://dhimmi.com
> I don't like cats! -- Come on, you just don't know how to cook them!
>
> ______________________________________________
> 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.



-- 
Jim Holtman
Data Munger Guru

What is the problem that you are trying to solve?
Tell me what you want to do, not how you want to do it.




More information about the R-help mailing list