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

From: Henrique Dallazuanna <wwwhsd_at_gmail.com>
Date: Tue, 29 Jan 2008 11:46:34 -0200

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 <Serguei.Kaniovski_at_wifo.ac.at> wrote:
> 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
> Arizona,2004,0.36
>
> Thank you in advance for your help,
> Serguei Kaniovski
>
> ______________________________________________
> R-help_at_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.
>

-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O

______________________________________________
R-help_at_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.
Received on Tue 29 Jan 2008 - 13:52:30 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 29 Jan 2008 - 14:30:08 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive