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

Webb Sprague webb.sprague at gmail.com
Wed Sep 23 23:39:50 CEST 2009


Note that the variable below has been generated with cut(), if that matters.

On Wed, Sep 23, 2009 at 2:34 PM, ws <webb.sprague at 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    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 :
>
>> table(JWMNP.cut, exclude=NULL)
> JWMNP.cut
>   [0,10)   [10,20)   [20,30)   [30,40)   [40,50)   [50,60)   [60,70)   [70,80)
>     8345     14708      9314      6317      3437       649      1287       232
>  [80,90)  [90,100) [100,110) [110,120) [120,130) [130,140) [140,150) [150,160)
>       58       296        57        19        89         6         3       108
> [160,170) [170,180) [180,190) [190,200) [200,Inf]      <NA>
>        0         0       154         0         0     60888
>
>> xtabs(~JWMNP.cut, exclude=NULL, na.action=na.pass)
> JWMNP.cut
>   [0,10)   [10,20)   [20,30)   [30,40)   [40,50)   [50,60)   [60,70)   [70,80)
>     8345     14708      9314      6317      3437       649      1287       232
>  [80,90)  [90,100) [100,110) [110,120) [120,130) [130,140) [140,150) [150,160)
>       58       296        57        19        89         6         3       108
> [160,170) [170,180) [180,190) [190,200) [200,Inf]
>        0         0       154         0         0
>
>> version
>               _
> platform       x86_64-unknown-linux-gnu
> arch           x86_64
> os             linux-gnu
> system         x86_64, linux-gnu
> status
> major          2
> minor          9.2
> year           2009
> month          08
> day            24
> svn rev        49384
> language       R
> version.string R version 2.9.2 (2009-08-24)
>
> ______________________________________________
> 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