From fe8baa03d40e6c3fdca3b612c88bdd74556cff2d Mon Sep 17 00:00:00 2001 From: tappek <77916431+tappek@users.noreply.github.com> Date: Sat, 28 Dec 2024 00:13:02 +0100 Subject: [PATCH] extact.data: faster as unnecessary conversions between matrix and data.frame are avoided --- R/est_gmm.R | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/R/est_gmm.R b/R/est_gmm.R index e7a9fd9..cd50ca7 100755 --- a/R/est_gmm.R +++ b/R/est_gmm.R @@ -710,12 +710,12 @@ extract.data <- function(data, as.matrix = TRUE){ X <- cbind(data[[1L]], X) colnames(X)[1L] <- deparse(trms[[2L]]) } - data <- collapse::rsplit(as.data.frame(X), index[[1L]], simplify = FALSE) - time <- collapse::gsplit(index[[2L]], index[[1L]], use.g.names = TRUE) + data <- if(!as.matrix) collapse::rsplit(as.data.frame(X), index[[1L]], simplify = FALSE) + else collapse::rsplit(X, index[[1L]], simplify = FALSE) + time <- collapse::gsplit(index[[2L]], index[[1L]]) data <- mapply( function(x, y){ rownames(x) <- y - if (as.matrix) x <- as.matrix(x) x } , data, time, SIMPLIFY = FALSE)