Skip to content

Commit

Permalink
extact.data: faster as unnecessary conversions between matrix and dat…
Browse files Browse the repository at this point in the history
…a.frame are avoided
  • Loading branch information
tappek committed Dec 27, 2024
1 parent c8ed7eb commit fe8baa0
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions R/est_gmm.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit fe8baa0

Please sign in to comment.