Revision 4de3e280a6f88cfcdfa131581cebe9aa005ec68a authored by Gilles Raiche on 10 April 2010, 00:00:00 UTC, committed by Gabor Csardi on 10 April 2010, 00:00:00 UTC
1 parent 875465d
eigenFrom.r
eigenFrom <-
function(x) {
classType <- class(x)
res <- switch (classType,
data.frame = "data",
matrix = "correlation",
numeric = "eigenvalues",
stop("Not a data.frame, a matrix, or a numeric vector")
)
switch (res,
data = if (dim(x)[2] <= 2) stop("At least 3 variables must be supplied"),
correlation = if (dim(x)[2] <= 2) stop("At least 3 variables must be supplied"),
eigenvalues = if (length(x) <= 2) stop("A vector of 3 eigenvalues or more must be supplied")
)
if (res == "correlation") if (any(x[lower.tri(x)] != t(x)[lower.tri(t(x))])) {
stop("A correlation/covariance matrix must be symetric, empirical data must
come from a data.frame, or eigenvalues must directly come from a vector.
Verify the documentation about the eigenFrom function.")
}
invisible(res)
}
![swh spinner](/static/img/swh-spinner.gif)
Computing file changes ...