[R] scatterplot matrix question

Uwe Ligges ligges at statistik.tu-dortmund.de
Sat Jan 2 19:22:39 CET 2010



William Simpson wrote:
> On Sat, Jan 2, 2010 at 4:55 PM, Charles C. Berry <cberry at tajo.ucsd.edu> wrote:
>> On Sat, 2 Jan 2010, William Simpson wrote:
>>
>>> I would like a scatterplot matrix and a correlation matrix for the
>>> following set-up.
>>> The data (dataframe d) are like this:
>>>
>>> angle  resp
>>> -90      182
>>> -60      137
>>> -30      ...etc
>>> 0
>>> 30
>>> 60
>>> 90
>>> ...etc
>>>
>>> I would like each cell in the matrix to be the scatterplot of the
>>> responses for each pair of angles ( -90 vs -60, -90 vs -30, etc). Same
>>> for the correlation matrix.
>>>
>>> Please tell me what to do. Thanks very much!
>> 1) You need to "provide commented, minimal, self-contained, reproducible
>>   code."
> d<-read.table("rstuff/data.dat",header=TRUE)
> 
> Now what? :-)
> 
> certainly it's not
> pairs(d)



Now that we are able to help with some more detailed view of your data 
(although you could have helped helping by making it easier for us to 
import your data into R), the answer is:

Almost, after reshaping:



dwide <- reshape(d, v.names="resp", idvar="ID",
                  timevar="angle", direction="wide")
pairs(dwide[,-1])


Best,
Uwe Ligges



> 
> 
>> 2) You need to fill in some missing info: Either you have only one
>>   response for each angle, or you need a third variable to pair up the
>>   corresponding responses for one angle with those of another.
> contents of rstuff/data.dat:
> 
>  angle  resp  ID
>  -90      182  1
>  -60      137  1
>  -30      123  1
>  0    67  1
>  30   32  1
>  60   12  1
>  90    13  1
> -90      178  2
>  -60      111  2
>  -30      137  2
>  0    94  2
>  30   59  2
>  60   1  2
>  90    19  2
> 
> I actually have a lot more than 2 experimental units (ID)...
> 
> Thanks for any help
> Bill
> 
> ______________________________________________
> 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.



More information about the R-help mailing list