[R] Data Manipulations - Group By equivalent

zubin binabina at bellsouth.net
Sun Jul 2 02:05:06 CEST 2006


Hello, a beginner R user - boy i wish there was a book on just data 
manipulations for SAS users learning R (equivalent to the SAS DATA 
STEP)..  Okay, my question: 

I have a panel data set, hotel data occupancy by month for 12 months, 
1000 hotels.  I have a field labeled 'year' and want to consolidate the 
monthly records using an average into 1000 occupancy numbers - just a 
simple average of the 12 months by hotel.  In SQL this operation is 
pretty easy, a group by query (group by hotel where year = 2005, avg 
occupancy) - how is this done in R? (in R language not SQL).  Thx!

-zubin



More information about the R-help mailing list