Skip to content

Commit

Permalink
Update mfairInitialization.R
Browse files Browse the repository at this point in the history
  • Loading branch information
statwangz committed Sep 16, 2023
1 parent 21fee28 commit 421dcff
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion R/mfairInitialization.R
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 421dcff

Please sign in to comment.