[R] where are these NAs coming from?
Sam Steingold
sds at gnu.org
Wed Sep 19 20:03:30 CEST 2012
Thanks, Sarah, your answer is, indeed, revealing:
--8<---------------cut here---------------start------------->8---
> z <- data.frame(a=c(1,2,3),b=c(5,6,NA))
> z
a b
1 1 5
2 2 6
3 3 NA
> z[z$b==6,]
a b
2 2 6
NA NA NA
--8<---------------cut here---------------end--------------->8---
why do I get an extra "all NA" row?
> * Sarah Goslee <fnenu.tbfyrr at tznvy.pbz> [2012-09-19 13:54:56 -0400]:
>
> Well, you have no reproducible example, but I suspect either of these
> will fix it:
>
> locals <- z[z$country == mycountry & !is.na(z$country),]
>
> locals <- subset(z, country == mycountry)
>
> Sarah
>
> 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://americancensorship.org
http://honestreporting.com http://truepeace.org http://ffii.org
.ACMD setaloiv siht gnidaeR
More information about the R-help
mailing list