[R] where are these NAs coming from?

Jeff Newmiller jdnewmil at dcn.davis.CA.us
Wed Sep 19 21:18:21 CEST 2012


"if I knew how to reproduce the problem, I would have known what was going on."

This is a worthless excuse. You are the one with the example in front of you.  I grant that paring it down to email size can take some time, but every second of that time is worthwhile, and at least half the battle is having data that triggers the problem. So learn to use dput() to put a few records of the offending data into each email when you put your code into the email, and give it a test drive pin a clean R environment and voila, you too can make a reproducible example.
---------------------------------------------------------------------------
Jeff Newmiller                        The     .....       .....  Go Live...
DCN:<jdnewmil at dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live Go...
                                      Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
/Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1k
--------------------------------------------------------------------------- 
Sent from my phone. Please excuse my brevity.

Sam Steingold <sds at gnu.org> wrote:

>> * jim holtman <wubygzna at tznvy.pbz> [2012-09-19 13:58:08 -0400]:
>>
>> At least provide a reproducible example by creating the problem with
>a
>> subset of 'z' and 'mycountry'
>
>if I knew how to reproduce the problem, I would have known what was
>going on.
>
>> Could something like this be happening?
>
>precisely, thanks!
>
>>> 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.




More information about the R-help mailing list