[R] How to calculate correlation of a vector in R?

Jeff Newmiller jdnewmil at dcn.davis.CA.us
Mon Nov 3 01:04:28 CET 2014

```What is your question? The matrix form is probably what you are looking for, but you put the same vector in three times so if course it is all ones. I don't know what you expected to happen when you entered cor(v) since there is nothing to correlate if you only have one vector.

Please post in plain text as the footer and Posting Guide request.
---------------------------------------------------------------------------
Jeff Newmiller                        The     .....       .....  Go Live...
DCN:<jdnewmil at dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live Go...
Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
/Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1k
---------------------------------------------------------------------------
Sent from my phone. Please excuse my brevity.

On November 2, 2014 3:30:14 PM PST, C W <tmrsg11 at gmail.com> wrote:
>Hi list,
>I have trying to calculate the covariance/correlation of three
>elements.  I
>have vector say,
>
>v <- c(700, 800, 1000)
>
>I want to have a 3 by 3 correlation matrix, meaning cor(v1, c2),
>cor(v1,
>c3), cor(v2, v3), etc...
>
>So far I get,
>> cor(v)
>Error in cor(v) : supply both 'x' and 'y' or a matrix-like 'x'
>
>> vvv <- cbind(v, v, v)
>> cor(vvv)
>  v v v
>v 1 1 1
>v 1 1 1
>v 1 1 1
>
>
>I am calculating squared exponential kernel as seen here.
>http://mlg.eng.cam.ac.uk/duvenaud/cookbook/index.html
>
>Thanks a bunch,
>
>Mike
>
>	[[alternative HTML version deleted]]
>
>______________________________________________
>R-help at r-project.org mailing list
>https://stat.ethz.ch/mailman/listinfo/r-help