Help on calculating spearman rank correlation for a data frame with conditions
id price distance 1 2 4 1 3 5 ... 2 4 8 2 5 9 I would like to calculate the rank-order correlation between price and distance for each id. cor(price,distance,method = "spearman") calculate a correlation for all.
Try by()
#Example
d <- data.frame(g=gl(5, 10), x=rnorm(50), y=rnorm(50))
by(d[,2:3], d$g, cor, method="spearman")
*******************************************************************
This email and any attachments are confidential. Any use...{{dropped:8}}