you should save your 3 variables into a new *dataframe*
d<-mydata[,c("iq","education","achievement")]
and then the command would be
by(d,d$sex,function(df) cor.test(df$educ,df$achiev))
but you could also just use
by(mydata,mydata$sex,function(df) cor.test(df$educ,df$achiev))
david freedman
I'm trying to obtain within-group correlations on a subset of variables. I
first selected my variables using the following command:
mydata$x<-mydata[c("iq","education","achievement")]
I'd like to look at correlations among those variables separately for men
and women. My gender variable in mydata
2 matches
Mail list logo