> 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}}

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to