[R] Pairwise cross correlation from data set

Claus O'Rourke claus.orourke at gmail.com
Sun Jun 13 19:47:59 CEST 2010


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!

Claus



More information about the R-help mailing list