Re: [R] Conditional Statistics

2013-01-08 Thread S Ellison
> ...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 m

Re: [R] Conditional Statistics

2013-01-08 Thread John Kane
I think Simon has provided a good answer to the actual question but as a refugee from SAS I'd suggest having a look at www.et.bs.ehu.es/~etptupaf/pub/R/RforSAS&SPSSusers.pdf or getting the book Muenchen, R. A. (2008). R for SAS and SPSS Users (1st ed.). Springer. R ans SAS approach things very

Re: [R] Conditional Statistics

2013-01-07 Thread Simon Blomberg
You can use the tapply function to do this. You can't type a line into the mean statement. (See ?mean for what you can type in there). The general approach is to have a vector of data (stock prices) and a categorical variable (day of week). Then break up the data vector according to the levels