[R] Conditional Statistics

S Ellison S.Ellison at LGCGroup.com
Tue Jan 8 14:43:01 CET 2013


> ...if I had the closing prices of the
> S&P from 01/01/1990-12/31/1990, how could I get the average price of
> the S&P from 02/01/1990-03/15/1990? Or the average price of the S&P on
> Mondays (assuming a dummy var is created for 1 = Monday, 0 = else). 

tapply has already been referred to. You may also find aggregate() useful, as it gives you back a data frame that includes the conditioning variables if you tell it to. Alse ave, if you want to do something like mean-centring a data set based on group means rather than the grad mean.

S Ellison

*******************************************************************
This email and any attachments are confidential. Any use...{{dropped:8}}




More information about the R-help mailing list