An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20090526/11d49f7d/attachment-0001.pl>
Still can't find missing data
5 messages · Farley, Robert, Dieter Menne
Farley, Robert <FarleyR <at> metro.net> writes:
What is wrong? I've looked into the na commands and the ?xtabs entry, but I
haven't found anything that works.
I never understood the logic that exclude=NULL needs na.action in addition. test <- c(1,2,3,1,2,3,NA,NA,1,2,3) xtabs(~test,exclude=NULL,na.action=na.pass) Dieter
I can't get the syntax that will allow me to show NA values (rows) in the xtabs.
# unfortunatly I don't see how to get that to run XTTable <- xtabs(wt_annual ~ Mode_orig_only + connector, exclude=NULL, na.action(na.pass), LAWAData)
Error in eval(expr, envir, enclos) : object "wt_annual" not found
XTTable <- xtabs(wt_annual ~ Mode_orig_only + connector, exclude=NULL, na.action(na.pass), drop.unused.levels = FALSE, LAWAData)
Error in eval(expr, envir, enclos) : object "wt_annual" not found
XTTable <- xtabs(wt_annual ~ Mode_orig_only + connector, na.action(na.pass), LAWAData)
Error in eval(expr, envir, enclos) : object "wt_annual" not found
XTTable <- xtabs(wt_annual ~ Mode_orig_only + connector, na.action(na.pass),drop.unused.levels = FALSE, LAWAData)
Error in eval(expr, envir, enclos) : object "wt_annual" not found
# ####### Those combinations that run w/o error give misleading results XTTable <- xtabs(wt_annual ~ Mode_orig_only + connector, exclude=NULL, LAWAData) XTTable
connector Mode_orig_only OD Passenger Connector Walked/Biked 17.814338 0.000000 I flew in from another a place/connected 0.000000 0.000000 Amtrak 49.128982 0.000000 Bus - Chartered bus or van 525.978899 0.000000 Bus - Hotel Courtesy van 913.295370 0.000000 Bus - MTA (Metro) or other public transit bus 114.302764 0.000000 Bus - Scheduled airport bus or van (e.g. Airport bus or Disn 298.151438 0.000000 Bus - Union Station Flyaway 93.088049 0.000000 Bus - Van Nuys Flyaway 233.794168 0.000000 Green line/light rail 20.764539 0.000000 Limousine/town car 424.120506 0.000000 Metrolink 8.054528 0.000000 Motorcycle 6.010790 0.000000 On-call shuttle/van (e.g. Super Shuttle, Prime Time) 1832.748525 0.000000 Car/truck/van - Private 10191.284139 0.000000 Car/truck/van - Rental 2099.771923 0.000000 Taxi 1630.148576 0.000000 ..Refused 0.000000 0.000000
XTTable <- xtabs(wt_annual ~ Mode_orig_only + connector, drop.unused.levels = FALSE, LAWAData) XTTable
connector Mode_orig_only OD Passenger Connector Walked/Biked 17.814338 0.000000 I flew in from another a place/connected 0.000000 0.000000 Amtrak 49.128982 0.000000 Bus - Chartered bus or van 525.978899 0.000000 Bus - Hotel Courtesy van 913.295370 0.000000 Bus - MTA (Metro) or other public transit bus 114.302764 0.000000 Bus - Scheduled airport bus or van (e.g. Airport bus or Disn 298.151438 0.000000 Bus - Union Station Flyaway 93.088049 0.000000 Bus - Van Nuys Flyaway 233.794168 0.000000 Green line/light rail 20.764539 0.000000 Limousine/town car 424.120506 0.000000 Metrolink 8.054528 0.000000 Motorcycle 6.010790 0.000000 On-call shuttle/van (e.g. Super Shuttle, Prime Time) 1832.748525 0.000000 Car/truck/van - Private 10191.284139 0.000000 Car/truck/van - Rental 2099.771923 0.000000 Taxi 1630.148576 0.000000 ..Refused 0.000000 0.000000
XTTable <- xtabs(wt_annual ~ Mode_orig_only + connector, exclude=NULL, drop.unused.levels = FALSE, LAWAData) XTTable
connector Mode_orig_only OD Passenger Connector Walked/Biked 17.814338 0.000000 I flew in from another a place/connected 0.000000 0.000000 Amtrak 49.128982 0.000000 Bus - Chartered bus or van 525.978899 0.000000 Bus - Hotel Courtesy van 913.295370 0.000000 Bus - MTA (Metro) or other public transit bus 114.302764 0.000000 Bus - Scheduled airport bus or van (e.g. Airport bus or Disn 298.151438 0.000000 Bus - Union Station Flyaway 93.088049 0.000000 Bus - Van Nuys Flyaway 233.794168 0.000000 Green line/light rail 20.764539 0.000000 Limousine/town car 424.120506 0.000000 Metrolink 8.054528 0.000000 Motorcycle 6.010790 0.000000 On-call shuttle/van (e.g. Super Shuttle, Prime Time) 1832.748525 0.000000 Car/truck/van - Private 10191.284139 0.000000 Car/truck/van - Rental 2099.771923 0.000000 Taxi 1630.148576 0.000000 ..Refused 0.000000 0.000000
version
_ platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status major 2 minor 8.1 year 2008 month 12 day 22 svn rev 47281 language R version.string R version 2.8.1 (2008-12-22)
sessionInfo() # List loaded packages
R version 2.8.1 (2008-12-22) i386-pc-mingw32 locale: LC_COLLATE=English_United States.1252;LC_CTYPE=English_United States.1252;LC_MONETARY=English_United States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252 attached base packages: [1] graphics grDevices utils datasets stats methods base other attached packages: [1] fortunes_1.3-6 prettyR_1.4 survey_3.10-1 foreign_0.8-29
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: Wednesday, May 27, 2009 02:52 To: r-help at stat.math.ethz.ch Subject: Re: [R] Still can't find missing data Farley, Robert <FarleyR <at> metro.net> writes:
What is wrong? I've looked into the na commands and the ?xtabs entry, but I
haven't found anything that works.
I never understood the logic that exclude=NULL needs na.action in addition. test <- c(1,2,3,1,2,3,NA,NA,1,2,3) xtabs(~test,exclude=NULL,na.action=na.pass) Dieter ______________________________________________ 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.
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.
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.