From 421dcff7550281bae84bdf4f6bae2057e47286e5 Mon Sep 17 00:00:00 2001 From: WANG Zhiwei <48282751+statwangz@users.noreply.github.com> Date: Sun, 17 Sep 2023 01:37:05 +0800 Subject: [PATCH] Update mfairInitialization.R --- R/mfairInitialization.R | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/R/mfairInitialization.R b/R/mfairInitialization.R index 46608f7..88b7492 100644 --- a/R/mfairInitialization.R +++ b/R/mfairInitialization.R @@ -46,13 +46,20 @@ createMFAIR <- function(Y, X, ) } # Otherwise, Y is not in sparse mode and we don't want it to be + # Do not store the complete matrix in the sparse mode + if(Y_sparse){ + if(length(Y@x) == N * M){ + stop("Please do not store the complete matrix in the sparse mode!") + } # End + } + # Center the matrix Y if (Y_center) { if (!Y_sparse) { Y_mean <- mean(Y, na.rm = TRUE) Y <- Y - Y_mean } else { - Y_mean <- mean(summary(Y)$x) + Y_mean <- mean(Y@x) Y@x <- Y@x - Y_mean } } else {