Skip to content
Prev 65290 / 398525 Next

Applying a function to all combinations of factors

you could use something  like

by(data, list(data1$day, data1$hour), function(x) cor(x[,"var1"], x[,
"var2"]))

This will return a list and then you can unlist and turn to matrix

HTH