Re: [R] Problem with xtabs(), exclude=NULL, and counting NA's

2009-09-24 Thread ws
Webb Sprague webb.sprague at gmail.com writes: xtabs(~wkhp, x, exclude=NULL, na.action=na.pass) wkhp  20   30   40   45   60 NA   1    1   10    1    3    4 now this doesn't even work table(wtf, exclude=NULL) wtf [0,10) [10,20) [20,30) [30,40) [40,50) [50,60)

Re: [R] Problem with xtabs(), exclude=NULL, and counting NA's

2009-09-24 Thread David Winsemius
On Sep 23, 2009, at 5:11 PM, ws wrote: Webb Sprague webb.sprague at gmail.com writes: xtabs(~wkhp, x, exclude=NULL, na.action=na.pass) wkhp 20 30 40 45 60 NA 11 10134 now this doesn't even work Try: wtf - factor(x, levels(c(levels(wtf), NA),

Re: [R] Problem with xtabs(), exclude=NULL, and counting NA's

2009-09-24 Thread David Winsemius
On Sep 24, 2009, at 3:06 AM, David Winsemius wrote: On Sep 23, 2009, at 5:11 PM, ws wrote: Webb Sprague webb.sprague at gmail.com writes: xtabs(~wkhp, x, exclude=NULL, na.action=na.pass) wkhp 20 30 40 45 60 NA 11 10134 now this doesn't even work Try:

Re: [R] Problem with xtabs(), exclude=NULL, and counting NA's

2009-09-24 Thread hadley wickham
wtf - factor(x, levels(c(levels(wtf), NA), exclude=NULL) xtabs (~ wtf, exclude=NULL, na.action=na.pass) Also see addNA. Hadley -- http://had.co.nz/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read

Re: [R] Problem with xtabs(), exclude=NULL, and counting NA's

2009-09-24 Thread David Winsemius
On Sep 24, 2009, at 10:06 AM, hadley wickham wrote: wtf - factor(x, levels(c(levels(wtf), NA), exclude=NULL) xtabs (~ wtf, exclude=NULL, na.action=na.pass) Also see addNA. That is nice. The addNA function does not exactly jump off the page for the (too) casual reader. In the context of

Re: [R] Problem with xtabs(), exclude=NULL, and counting NA's

2009-09-24 Thread Webb Sprague
Also see addNA. Works great. Sometimes R drives me crazy, but Hadley, you make it much easier for me That is nice. The addNA function does not exactly jump off the page for the (too) casual reader. In the context of the OP's original problem, these lines of code are illustrative: Here

Re: [R] Problem with xtabs(), exclude=NULL, and counting NA's

2009-09-23 Thread ws
Webb Sprague webb.sprague at gmail.com writes: xtabs(~wkhp, x, exclude=NULL, na.action=na.pass) wkhp  20   30   40   45   60 NA   1    1   10    1    3    4 (Forgive me for the repost, but I just joined the R list, so maybe this will go through.) Now the above doesn't work! See :

Re: [R] Problem with xtabs(), exclude=NULL, and counting NA's

2009-09-23 Thread Webb Sprague
Note that the variable below has been generated with cut(), if that matters. On Wed, Sep 23, 2009 at 2:34 PM, ws webb.spra...@gmail.com wrote: Webb Sprague webb.sprague at gmail.com writes: xtabs(~wkhp, x, exclude=NULL, na.action=na.pass) wkhp  20   30   40   45   60 NA   1    1   10  

Re: [R] Problem with xtabs(), exclude=NULL, and counting NA's

2009-09-05 Thread Webb Sprague
xtabs(~wkhp, x, exclude=NULL, na.action=na.pass) wkhp  20   30   40   45   60 NA   1    1   10    1    3    4 Thanks! I must say that this is slightly odd behavior to require both na.action= AND exclude=. Does anyone know of a justification? Shouldn't it be changed? vent Ah well, if R were

Re: [R] Problem with xtabs(), exclude=NULL, and counting NA's

2009-09-05 Thread Mark Difford
I must say that this is slightly odd behavior to require both na.action= AND exclude=. Does anyone know of a justification? Not strange at all. ?options na.action, sub head Options set in package stats. You need to override the default setting. ws-7 wrote: xtabs(~wkhp, x, exclude=NULL,

[R] Problem with xtabs(), exclude=NULL, and counting NA's

2009-09-04 Thread ws
Hi all, I cannot get xtabs to count NA's like I expect. Below is a sample session, and note that the last two calls to xtabs() yield exactly the same thing. I am running R-2.5.0 -- if there was a bug in xtabs that got fixed, I would love to know about it. If there is a bug tracker somewhere,

Re: [R] Problem with xtabs(), exclude=NULL, and counting NA's

2009-09-04 Thread David Winsemius
On Sep 4, 2009, at 7:49 PM, ws wrote: Hi all, I cannot get xtabs to count NA's like I expect. Below is a sample session, and note that the last two calls to xtabs() yield exactly the same thing. I am running R-2.5.0 -- if there was a bug in xtabs that got fixed, I would love to know