[R] descriptive statistics

Jim Lemon jim at bitwrit.com.au
Mon Dec 13 11:23:15 CET 2010


On 12/13/2010 09:04 PM, effeesse wrote:
>
> Hi. In a data set I have a variable that takes values from 1 to 14. For each
> subgroup of values of this variable, I would like to obtain some descriptive
> statistics of other variables present in the data set. I've been trying with
> a "for" loop but I couldn't get nothing. Could you please suggest me some
> lines?

Hi effeesse,
Sure:

testmat<-data.frame(sample(1:14,50,TRUE),rnorm(50),runif(50))
by(testmat[,-1],testmat[,1],mean)

Jim



More information about the R-help mailing list