[R] Pairwise cross correlation from data set

From: Claus O'Rourke <claus.orourke_at_gmail.com>
Date: Sun, 13 Jun 2010 18:47:59 +0100

Dear list,

Following up on an earlier post, I would like to reorder a dataset and compute pairwise correlations. But I'm having some real problems getting this done.

My data looks something like:

Participant Stimulus Measurement

 p1                 s`1            5
 p1                 s`2            6.1
 p1                 s`3            7
 p2                 s`1            4.8
 p2                 s`2            6
 p2                 s`3            6.5
 p3                 s`1            4
 p3                 s`2            7
 p3                 s`3            6

As a first step I would imagine that I have to rearrange my data into a frame more like this

Stimulus  p1   p2      p3
   s1       5      4.8     4
   s2       6.1   6        7
   s3       7      6.5     6

And then do the pairwise correlations between {p1,p2},{p2,p3}.{p2,p3}

I can do all of this manually, i.e., using some messy case specific code, but can anyone please point out the best way to do this in a more generalizable way.

Thanks for any help you can give a novice!


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 Sun 13 Jun 2010 - 17:51:01 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 Sun 13 Jun 2010 - 18:30:29 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