[R] how to get the mean of each group?

ronggui 0034058 at fudan.edu.cn
Sun Jun 19 14:57:35 CEST 2005


i have the data x.1

>x.1 <- data.frame(income=runif(100)*10000,
+ edu=sample(c('hs','col','none'),100,T),y=rnorm(100)*100)

and i want to get :

       income         y
col  5526.726 -11.00956
hs   4196.036 -10.03861
none 4308.111 -28.69549

5526.726 is the mean income for col, 4196.036 is the  mean income for hs......



-- 
Department of Sociology
Fudan University,Shanghai
Blog:http://sociology.yculblog.com




More information about the R-help mailing list