[R] Using tapply to create a new table

Kalish, Josh josh.kalish at credit-suisse.com
Fri Jan 26 18:39:29 CET 2007


I'm sure that this is covered somewhere, but I can't seem to find a good explanation.  I have an existing table that contains information grouped by date.  This is as so:

Day		NumberOfCustomers		NumberOfComplaints
20060512	10040				40
20060513	32420				11

I also have a table at the detail level as so:

Day		Meal		PricePaid	UsedCupon
20060512	Fish		14		Y
20060512	Chicken	20		N

Is there a simple way to create summaries on the detail table and then join them into the first table above so that it looks like this:

Day		NumberOfCustomers		NumberOfComplaints	AveragePricePaid		NumberUsingCupon

I can do a tapply to get what I want from the detail table, but I can't figure out how to turn that into a table and join it back in.



Please access the attached hyperlink for an important electr...{{dropped}}

More information about the R-help mailing list