My data frame (g) contains 2 columns with continues data and other columns with categorical data. I want to test for correlations between the 2 continues variables, in diffe
If I understand right, you want to compute the correlations between GDW and GN for every value in the column M1 (that is, by splitting at every unique value of M1).
Using Hadley's plyr
require(plyr)
# assuming the data.frame is df (Note: factor M1 if necessary)
daply(df, .(M1), function(y) cor(y$GDW, y$GN))