これはvegan::designdist()
で実施することができる
ジェームズが、唯一のterms="minimum"
のための現在の設計と。バイナリデータは、入力の0/1変換で直接R
またはdecostand(..., "pa")
を使用して処理する必要があります。次の変更はvegan::designdist()
で行います。
--- a/R/designdist.R
+++ b/R/designdist.R
@@ -1,7 +1,7 @@
`designdist` <-
function (x, method = "(A+B-2*J)/(A+B)",
terms = c("binary", "quadratic", "minimum"),
- abcd = FALSE, alphagamma = FALSE, name)
+ abcd = FALSE, alphagamma = FALSE, name, na.rm = FALSE)
{
terms <- match.arg(terms)
if ((abcd || alphagamma) && terms != "binary")
@@ -9,13 +9,16 @@
x <- as.matrix(x)
N <- nrow(x)
P <- ncol(x)
+ ## check NA
+ if (na.rm && terms != "minimum" && any(is.na(x)))
+ stop("'na.rm = TRUE' can only be used with 'terms = \"minimum\"\' ")
if (terms == "binary")
x <- ifelse(x > 0, 1, 0)
if (terms == "binary" || terms == "quadratic")
x <- tcrossprod(x)
if (terms == "minimum") {
- r <- rowSums(x)
- x <- dist(x, "manhattan")
+ r <- rowSums(x, na.rm = na.rm)
+ x <- vegdist(x, "manhattan", na.rm = na.rm)
x <- (outer(r, r, "+") - as.matrix(x))/2
}
d <- diag(x)