In R, I have a data frame comprising a class label C (a factor) and two measurements, M1 and M2. How do I compute the correlation between M1 and M2 within each class?
Ideally, I'd get back a data frame with one row for each class and two columns: the class label C and the correlation.