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

C W tmrsg11 at gmail.com
Mon Nov 3 00:30:14 CET 2014


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]]



More information about the R-help mailing list