From 0b52b45e1d66584c77285fa9e12fde95e9277012 Mon Sep 17 00:00:00 2001 From: WANG Zhiwei <48282751+statwangz@users.noreply.github.com> Date: Sun, 17 Sep 2023 01:15:30 +0800 Subject: [PATCH] Style the code --- R/mfairInitialization.R | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/R/mfairInitialization.R b/R/mfairInitialization.R index 4b97862..1fc2f37 100644 --- a/R/mfairInitialization.R +++ b/R/mfairInitialization.R @@ -27,18 +27,20 @@ createMFAIR <- function(Y, X, Y_sparse = FALSE, Y_center = TRUE, K_max = 1L, pro } # End # Check whether to transfer Y to the sparse matrix mode - if(class(Y) == "dgCMatrix"){ # Y is already in sparse mode + if (class(Y) == "dgCMatrix") { # Y is already in sparse mode Y_sparse <- TRUE - }else if(Y_sparse == TRUE){ # Y is not in sparse mode, but we want it to be + } else if (Y_sparse == TRUE) { # Y is not in sparse mode, but we want it to be obs_tf <- !is.na(Y) # Indicates whether observed or missing - obs_idx <- which(obs_tf, arr.ind=TRUE) # Indices of observed entries - Y <- Matrix::sparseMatrix(i = obs_idx[, "row"], - j = obs_idx[, "col"], - x = Y[obs_tf], - dims = c(N, M), - symmetric = FALSE, triangular = FALSE, - index1 = TRUE, - repr = "C") + obs_idx <- which(obs_tf, arr.ind = TRUE) # Indices of observed entries + Y <- Matrix::sparseMatrix( + i = obs_idx[, "row"], + j = obs_idx[, "col"], + x = Y[obs_tf], + dims = c(N, M), + symmetric = FALSE, triangular = FALSE, + index1 = TRUE, + repr = "C" + ) } # Otherwise, Y is not in sparse mode and we don't want it to be # Center the matrix Y