[R] Compute correlation matrix for panel data with specific ordering
Serguei Kaniovski
Serguei.Kaniovski at wifo.ac.at
Sat Jun 27 01:56:52 CEST 2009
Hello All,
I have a panel date - here a small-scale example:
df <-
data.frame(cbind(rep(c("AUT","BEL","DEN","GER"),4),cbind(rep(c(1999,2000,2001,2002),4)),sample(10,16,replace=T)))
names(df) <- c("country","year","x")
SORT <- c("GER","BEL","DEN","AUT")
I need to compute the correlation between countries in the variable "x"
in such a way that the rows & columns of the resulting correlation
matrix are not in an alphabetical order but in the order of a given
factor vector - here SORT.
How can I do this? Greatly appreciate any help!
Serguei Kaniovski
More information about the R-help
mailing list