From 03739cb13678c7ff7ea1c2f37253792099e3dca3 Mon Sep 17 00:00:00 2001 From: Emil Hvitfeldt Date: Tue, 3 Jun 2025 14:42:08 -0700 Subject: [PATCH] only normalize in pls_project() if we need to --- R/pls.R | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/R/pls.R b/R/pls.R index 7c24e2cd2..85f1181d7 100644 --- a/R/pls.R +++ b/R/pls.R @@ -318,7 +318,9 @@ pls_project <- function(object, x) { x <- as.matrix(x) } z <- sweep(x, 2, STATS = object$mu, "-") - z <- sweep(z, 2, STATS = object$sd, "/") + if (!is.null(object$sd)) { + z <- sweep(z, 2, STATS = object$sd, "/") + } res <- z %*% object$coefs res <- tibble::as_tibble(res) res <- purrr::map2_dfc(res, object$col_norms, \(.x, .y) .x * .y)