Skip to content

where are these NAs coming from?

9 messages · Sarah Goslee, jim holtman, Sam Steingold +2 more

#
I see this:
--8<---------------cut here---------------start------------->8---
[1] 0
[1] 229
--8<---------------cut here---------------end--------------->8---
where are those locals without the language coming from?!
#
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:
#
At least provide a reproducible example by creating the problem with a
subset of 'z' and 'mycountry'

Could something like this be happening?
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:

  
    
#
Thanks, Sarah, your answer is, indeed, revealing:
--8<---------------cut here---------------start------------->8---
a  b
1 1  5
2 2  6
3 3 NA
a  b
2   2  6
NA NA NA
--8<---------------cut here---------------end--------------->8---
why do I get an extra "all NA" row?

  
    
#
On 19/09/2012 1:50 PM, Sam Steingold wrote:
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
#
R doesn't know whether the missing (NA) value is 6 or not, so by
default it returns it so the user can make up her own mind.

If you're using square brackets for subsetting, you need to explicitly
handle NA cases. If using subset(), the default behavior is to remove
them.

?"["
explains this.

Sarah
On Wed, Sep 19, 2012 at 2:03 PM, Sam Steingold <sds at gnu.org> wrote:

  
    
#
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:

            
#
if I knew how to reproduce the problem, I would have known what was going on.
precisely, thanks!

  
    
#
"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: