[R] How do I get xtabs to show missing data?
dwinsemius at comcast.net
dwinsemius at comcast.net
Thu Feb 19 04:47:46 CET 2009
Try setting exclude=NULL if you think that the NA's need to be considered as a value.
The default is to exclude both NaN and NA.
--
David Winsemius
-------------- Original message ----------------------
From: "Farley, Robert" <FarleyR at metro.net>
> I presume the behavior below (no Connector values in the second table)
> is because I have na values in my dataframe. How do I get them to list?
>
>
>
> I found references to na.action and na.pass, but I could not figure out
> how I could use them with xtabs to list the na as a value. I'm sure
> there's a simple syntax I need, but it's not obvious to me.
>
>
>
>
>
>
>
>
>
>
>
> > # Weighted Data
>
> > XTTable <- xtabs(wt_annual ~ time_strata + connector, LAWAData)
>
> > XTTable ## List
>
> connector
>
> time_strata OD Passenger Connector
>
> Morning Peak - 0550 to 0959 5605.140 1234.933
>
> Late morning to Mid-Day - 1000 to 1359 4778.503 2516.943
>
> Evening Peak - 1400 to 1959 5145.730 3171.348
>
> Night - 2000 to 0235 (last flight) 2929.085 2567.790
>
> >
>
> > XTTable <- xtabs(wt_annual ~ Mode_orig_only + connector, LAWAData)
>
> > XTTable ## List
>
> 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
>
> >
>
>
>
>
>
>
>
> Robert Farley
>
> Metro
>
> 1 Gateway Plaza
>
> Mail Stop 99-23-7
>
> Los Angeles, CA 90012-2952
>
> Voice: (213)922-2532
>
> Fax: (213)922-2868
>
> www.Metro.net
>
>
>
>
>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> 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