Skip to content

scatterplot matrix question

7 messages · William Simpson, Charles C. Berry, Uwe Ligges +1 more

#
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!

Bill
#
On Sat, 2 Jan 2010, William Simpson wrote:

            
1) You need to "provide commented, minimal, self-contained, reproducible
    code."

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.

Chuck
NOTE:.^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Charles C. Berry                            (858) 534-2098
                                             Dept of Family/Preventive Medicine
E mailto:cberry at tajo.ucsd.edu	            UC San Diego
http://famprevmed.ucsd.edu/faculty/cberry/  La Jolla, San Diego 92093-0901
#
On Sat, Jan 2, 2010 at 4:55 PM, Charles C. Berry <cberry at tajo.ucsd.edu> wrote:
d<-read.table("rstuff/data.dat",header=TRUE)

Now what? :-)

certainly it's not
pairs(d)
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
#
William Simpson wrote:
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
#
I am preparing for the data analysis, writing the code (knowing I may
have to modify it later) while the data are still being collected.
That's why I used the artificial data when asked for some. I will be
pressed for time when the data arrive.
Thanks very much, Uwe. I will try this (on artificial data). I think
reshape() requires a library [reshape?].

Bill
#
On Jan 2, 2010, at 1:49 PM, William Simpson wrote:

            
No. In fact, the reshape package does not have a reshape function.

--

David Winsemius, MD
Heritage Laboratories
West Hartford, CT
#
OK thanks David