Re: [R] Correlation matrix for data in long format

2008-01-29 Thread Henrique Dallazuanna
If I understand your question, you can try something like this: cor(data.frame(lapply(split(x, x$state), "[", 3))) On 29/01/2008, Serguei Kaniovski <[EMAIL PROTECTED]> wrote: > Hello, > > I cannot figure out how to use "tapply" to compute the correlation matrix > in the variable "x" between the s

[R] Correlation matrix for data in long format

2008-01-29 Thread Serguei Kaniovski
Hello, I cannot figure out how to use "tapply" to compute the correlation matrix in the variable "x" between the states? The data is in long format, e.g.: state,year,x Alabama,2001,0.45 Alabama,2002,0.47 Alabama,2003,0.48 Alabama,2004,0.44 Arizona,2001,0.34 Arizona,2002,0.32 Arizona,2003,0.38 Ar