That's very helpful Michael, thank you. I will add it to the arsenal.
--
View this message in context:
http://r.789695.n4.nabble.com/Covariance-Variance-Matrix-and-For-Loops-tp3859441p3863098.html
Sent from the R help mailing list archive at Nabble.com.
_
Surprising: must be newer update than I realizedanyways, here's
the code if you want to add it manually:
simplify2array <-
function (x, higher = TRUE)
{
if (length(common.len <- unique(unlist(lapply(x, length >
1L)
return(x)
if (common.len == 1L)
unlist(x,
Hello again,
sapply works.
However it does not explicitly call a simplify function, but rather seems to
handle the case within its own body of code. I should be able to figure out
basically what simplify2array does from the code though.
function (X, FUN, ..., simplify = TRUE, USE.NAMES = TRUE)
I don't have access to older versions of R right now, but if you have a recent
install you are probably running 2.13.1 or 2.13.0. Can you run the following:
X <- list(a= rnorm(5), b= rnorm(5))
sapply(X, min)
?
sapply calls simplify2array() so if this works take a look at the code for
sapply (j
Thank you Michael.
I think my initial problem may have been due to a 'clerical error' upriver,
so I appreciate you taking the time to give me this help.
Unfortunately, my version of R does not contain simplify2array() and does
not find it in help (?simplify2array) - which is strange because I jus
Without seeing cvm1_list, I can't guarantee this will work, but consider this:
testList = list(rnorm(500), rnorm(500), rnorm(500), rnorm(500), rnorm(500))
testMat = simplify2array(testList)
covTest = cov(testMat)
Running your code works on my testList, so I can't help there without
a reproducible
Hello,
I am very new to R (as my Subject probably indicates).
I want to do something that should, I think, be very simple. I have five
vectors in a list and I want to construct a covariance matrix out of them.
Given a 5X5 matrix cvm1, and the list of vectors, cvm1_list, I thought the
following w
7 matches
Mail list logo