Skip to content

Commit c412af4

Browse files
committed
accept distances in symmetric square matrix per wish of issue #497
Distances in symmetric square matrix are handled similarly as in dbRDA.
1 parent 6a5f9b3 commit c412af4

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

R/varpart.R

+5
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,14 @@
77
X <- list(X, ...)
88
if ((length(X) < 2 || length(X) > 4))
99
stop("needs two to four explanatory tables")
10+
## see if distances were given in non-canonical form as a symmetric matrix
11+
if ((is.matrix(Y) || is.data.frame(Y)) && isSymmetric(unname(as.matrix(Y))))
12+
Y <- as.dist(Y)
1013
## transfo and scale can be used only with non-distance data
1114
if (inherits(Y, "dist")) {
1215
inert <- attr(Y, "method")
16+
if (is.null(inert))
17+
inert <- "unknown user-supplied"
1318
inert <- paste(paste0(toupper(substring(inert, 1, 1)),
1419
substring(inert, 2)), "distance")
1520
## sqrt of distances?

0 commit comments

Comments
 (0)