[R] Simple (?) subset problem

Erik Iverson iverson at biostat.wisc.edu
Fri Aug 15 00:47:01 CEST 2008


I can't tell exactly what's wrong, just check out the ?str and ?levels 
functions for some guidance.

Farley, Robert wrote:
> I can't figure out the syntax I need to get subset to work.  I'm trying
> to split my dataframe into two parts.  I'm sure this is a simple issue,
> but I'm stumped.  I either get all or none of the original "rows".  
> 
>  
> 
>  
> 
>  
> 
>  
> 
>> XTTable <- xtabs( ~   direction_ , SurveyData)
> 
>> XTTable
> 
> direction_
> 
> EASTBOUND                                          
> 
>                                                345 
> 
> WESTBOUND                                          
> 
>                                                307 
> 
>> EBSurvey <- subset(SurveyData, direction_ == "EASTBOUND" )
> 
>> XTTable <- xtabs( ~   direction_ , EBSurvey)
> 
>> XTTable
> 
> direction_
> 
> EASTBOUND                                          
> 
>                                                  0 
> 
> WESTBOUND                                          
> 
>                                                  0 
> 
>> EBSurvey <- subset(SurveyData, direction_ = "EASTBOUND" )
> 
>> XTTable <- xtabs( ~   direction_ , EBSurvey)
> 
>> XTTable
> 
> direction_
> 
> EASTBOUND                                          
> 
>                                                345 
> 
> WESTBOUND                                          
> 
>                                                307 
> 
>> EBSurvey <- subset(SurveyData, direction_ == 1 )
> 
>> XTTable <- xtabs( ~   direction_ , EBSurvey)
> 
>> XTTable
> 
> direction_
> 
> EASTBOUND                                          
> 
>                                                  0 
> 
> WESTBOUND                                          
> 
>                                                  0 
> 
> 
>  
> 
>  
> 
>  
> 
>  
> 
> 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