[R] Covariance-Variance Matrix and For Loops
sf1979
simonfuller9 at gmail.com
Sat Oct 1 10:22:09 CEST 2011
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)
{
FUN <- match.fun(FUN)
answer <- lapply(X, FUN, ...)
if (USE.NAMES && is.character(X) && is.null(names(answer)))
names(answer) <- X
if (simplify && length(answer) && length(common.len <-
unique(unlist(lapply(answer,
length)))) == 1L) {
if (common.len == 1L)
unlist(answer, recursive = FALSE)
else if (common.len > 1L) {
r <- as.vector(unlist(answer, recursive = FALSE))
if (prod(d <- c(common.len, length(X))) == length(r))
array(r, dim = d, dimnames = if (!(is.null(n1 <-
names(answer[[1L]])) &
is.null(n2 <- names(answer))))
list(n1, n2))
else answer
}
else answer
}
else answer
}
<environment: namespace:base>
--
View this message in context: http://r.789695.n4.nabble.com/Covariance-Variance-Matrix-and-For-Loops-tp3859441p3862347.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list