[R] by group
Val
v@|kremk @end|ng |rom gm@||@com
Mon Nov 1 22:08:13 CET 2021
Hi All,
How can I generate mean by group. The sample data looks like as follow,
dat<-read.table(text="Year Sex wt
2001 M 15
2001 M 14
2001 M 16
2001 F 12
2001 F 11
2001 F 13
2002 M 14
2002 M 18
2002 M 17
2002 F 11
2002 F 15
2002 F 14
2003 M 18
2003 M 13
2003 M 14
2003 F 15
2003 F 10
2003 F 11 ",header=TRUE)
The desired output is,
M F
2001 15 12
2002 16.33 13.33
2003 15 12
Thank you,
More information about the R-help
mailing list