From e884c223f4230cf00ffabe075b99a103d935137a Mon Sep 17 00:00:00 2001 From: Jari Oksanen Date: Tue, 28 May 2024 14:56:29 +0300 Subject: [PATCH 1/2] dist2xy: keep/set attributes of input dissimilarities --- R/dist2xy.R | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/R/dist2xy.R b/R/dist2xy.R index 4f5952518..761f44e6d 100644 --- a/R/dist2xy.R +++ b/R/dist2xy.R @@ -51,6 +51,7 @@ type <- match.arg(type) if (!inherits(dist, "dist")) stop("'dist' must be a dissimilarity object of class 'dist'") + att <- attributes(dist) dist <- as.matrix(dist) n <- nrow(dist) ## make up the selection vector @@ -59,9 +60,13 @@ if (invert) k <- !k ## make compartments - if (type == "xy") - dist[k, !k, drop = FALSE] - else - as.dist(dist[k, k, drop = FALSE]) + dist <- if (type == "xy") + dist[k, !k, drop = FALSE] + else + as.dist(dist[k, k, drop = FALSE]) + attr(dist, "call") <- match.call() + attr(dist, "method") <- att$method + attr(dist, "maxdist") <- att$maxdist + dist } From bb8b7079528db4964a790d736c9310b9d978216f Mon Sep 17 00:00:00 2001 From: Jari Oksanen Date: Tue, 28 May 2024 14:58:17 +0300 Subject: [PATCH 2/2] update tests/Examples --- tests/Examples/vegan-Ex.Rout.save | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/Examples/vegan-Ex.Rout.save b/tests/Examples/vegan-Ex.Rout.save index b75c69ff7..ef5e9a63f 100644 --- a/tests/Examples/vegan-Ex.Rout.save +++ b/tests/Examples/vegan-Ex.Rout.save @@ -187,17 +187,17 @@ adj. RDA R squares -0.12553 -0.0250 > MDSaddpoints(mod3, dist2xy(d, 3)) $points MDS1 MDS2 -3 -0.04351138 -0.2040447 +3 -0.09726945 -0.4560911 $seed - [,1] [,2] -[1,] 0.005468615 -0.1947698 + [,1] [,2] +[1,] 0.01222408 -0.435372 $deltastress [1] 0.001811369 $iters -[1] 16 +[1] 18 $cause [1] 4 @@ -8948,7 +8948,7 @@ Procrustes sum of squares: > cleanEx() > options(digits = 7L) > base::cat("Time elapsed: ", proc.time() - base::get("ptime", pos = 'CheckExEnv'),"\n") -Time elapsed: 8.578 0.271 8.874 0 0 +Time elapsed: 8.559 0.295 8.885 0 0 > grDevices::dev.off() null device 1