[R] Mutliple sets of data in one dataset....Need a loop?
David Freedman
3.14david at gmail.com
Wed Jan 20 19:08:37 CET 2010
You'll probably want to look at the 'by' function
d=data.frame(sex=rep(1:2,50),x=rnorm(100))
d$y=d$x+rnorm(100)
head(d)
cor(d)
by(d[,-1],d['sex'],function(df)cor(df))
You might also want to look at the doBy package
--
View this message in context: http://n4.nabble.com/Mutliple-sets-of-data-in-one-dataset-Need-a-loop-tp1018503p1018616.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list