Re: [R] Correlation Matrix

From: Jorge Ivan Velez <jorgeivanvelez_at_gmail.com>
Date: Thu, 07 Apr 2011 15:25:17 -0400

I am sorry for the noise, but

with(MyDataFrame[, 1:3])

should have been

with(cor(MyDataFrame[, 1:3]))

Best,
Jorge

On Thu, Apr 7, 2011 at 3:21 PM, Jorge Ivan Velez <> wrote:

> Hi Dmitry,
>
> You might try
>
> with(MyDataFrame[, 1:3])
>
> is variable1, variable2 and variable3 correspond to the first three columns
> of your data, or
>
> with( MyDataFrame( cor( cbind( variable1, variable2, variable3) ) ) )
>
> otherwise.
>
> HTH,
> Jorge
>
>
>
> On Thu, Apr 7, 2011 at 3:09 PM, Dmitry Berman <> wrote:
>
>> Listers,
>>
>> I have a question regarding correlation matrices. It is fairly straight
>> forward to build a correlation matrix of an entire data frame. I simply
>> use
>> the command cor(MyDataFrame). However, what I would like to do is
>> construct
>> a smaller correlation matrix using just three of the variable out of my
>> data
>> set.
>>
>> When I run this:
>> cor(MyDataFrame$variable1, MyDataFrame$variable2,MyDataFrame$variable3) I
>> get an error.
>>
>> Is there a way to do this through a built in function or is this something
>> I
>> have to construct manually?
>>
>> Thanks
>>
>> [[alternative HTML version deleted]]
>>
>> ______________________________________________
>> 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.
>>
>
>

        [[alternative HTML version deleted]]



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 Thu 07 Apr 2011 - 19:31:06 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 Thu 07 Apr 2011 - 20:10:28 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