[R] Still can't find missing data

Farley, Robert FarleyR at metro.net
Fri May 29 01:09:32 CEST 2009


In this toy data, each of the tables should sum to 1111
None of the tables shows NA columns or rows.


> ################################
> ToyData <- read.table("C:/Data/R/Toy.csv", header=TRUE, sep=",", na.strings="NA", dec=".", row.names="ID_Num")
> ToyData
    Data1 Data2  Data3 Weight
101   Sam   Red Banana      1
102   Sam Green Banana      2
103   Sam  Blue Orange      2
104  Fred   Red Orange      2
105  Fred Green  Guava      2
106  Fred  Blue  Guava      2
107  <NA>   Red   Pear     50
108  <NA> Green   Pear     50
109  <NA>  Blue   <NA>   1000
> xtabs(Weight ~  Data1 + Data2, exclude=NULL, na.action=na.pass, ToyData)
      Data2
Data1  Blue Green Red
  Fred    2     2   2
  Sam     2     2   1
> xtabs(Weight ~  Data1 + Data2, exclude=NULL, na.action=na.pass,drop.unused.levels = FALSE, ToyData)
      Data2
Data1  Blue Green Red
  Fred    2     2   2
  Sam     2     2   1
> xtabs(Weight ~  Data1 + Data3, exclude=NULL, na.action=na.pass,drop.unused.levels = FALSE, ToyData)
      Data3
Data1  Banana Guava Orange Pear
  Fred      0     4      2    0
  Sam       3     0      2    0
>





Robert Farley
Metro
www.Metro.net


-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of Dieter Menne
Sent: Thursday, May 28, 2009 05:46
To: r-help at r-project.org
Subject: Re: [R] Still can't find missing data




Farley, Robert wrote:
>
> I can't get the syntax that will allow me to show NA values (rows) in the
> xtabs.
>
> lengthy non-reproducible example removed
>

If you want a reproducible answer, prepare a reproducible result. And check
that the
syntax is

na.action=na.pass

Dieter




--
View this message in context: http://www.nabble.com/Still-can%27t-find-missing-data-tp23730627p23761006.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
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