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!
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?! >-- Sarah Goslee http://www.functionaldiversity.org
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,] > zcountry 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.
On 19/09/2012 1:50 PM, Sam Steingold 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?! >Why not look? z may be big, but which(is.na(locals$language)) only contains 229 values, and you could look at the z rows for those (or the first few of them if 229 is too many). Duncan Murdoch
I don't. You are getting to be a regular around here, so you should know better by now. Please stop posting non-reproducible sample code. --------------------------------------------------------------------------- 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:>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?!