From 17ddc7c501a3d21faa559d5d8a20f2241f1dfb5a Mon Sep 17 00:00:00 2001 From: Felix Held Date: Fri, 22 Nov 2024 15:11:20 +0100 Subject: [PATCH] remove redundant assignments --- R/scregclust.R | 39 ++++++++++----------------------------- 1 file changed, 10 insertions(+), 29 deletions(-) diff --git a/R/scregclust.R b/R/scregclust.R index 998c528..a97127f 100644 --- a/R/scregclust.R +++ b/R/scregclust.R @@ -197,6 +197,16 @@ scregclust <- function(expression, # START input validation ############################### + # This one needs to happen first so we can use it for input validation + if (!( + is.logical(verbose) + && length(verbose) == 1 + )) { + cli::cli_abort( + "{.var verbose} needs to be TRUE or FALSE." + ) + } + if (verbose) { cat(paste0(cli::symbol$arrow_right, " Validating input")) cl <- TRUE @@ -225,8 +235,6 @@ scregclust <- function(expression, "i" = "There needs to be one gene symbol for each gene in {.var expression}." )) - } else { - genesymbols <- genesymbols } if (!( @@ -357,8 +365,6 @@ scregclust <- function(expression, "for each column of {.var expression}." ) )) - } else { - sample_assignment <- sample_assignment } if (!( @@ -372,8 +378,6 @@ scregclust <- function(expression, cli::cli_abort( "{.var center} needs to be TRUE or FALSE." ) - } else { - center <- center } # If no split indices are provided, then the data split is determined @@ -630,8 +634,6 @@ scregclust <- function(expression, cli::cli_abort( "{.var allocate_per_obs} needs to be TRUE or FALSE." ) - } else { - allocate_per_obs <- allocate_per_obs } if (!( @@ -678,8 +680,6 @@ scregclust <- function(expression, cli::cli_abort( "{.var use_kmeanspp_init} needs to be TRUE or FALSE." ) - } else { - use_kmeanspp_init <- use_kmeanspp_init } if (!( @@ -771,8 +771,6 @@ scregclust <- function(expression, cli::cli_abort( "{.var compute_predictive_r2} needs to be TRUE or FALSE." ) - } else { - compute_predictive_r2 <- compute_predictive_r2 } if (!( @@ -786,23 +784,6 @@ scregclust <- function(expression, cli::cli_abort( "{.var compute_silhouette} needs to be TRUE or FALSE." ) - } else { - compute_silhouette <- compute_silhouette - } - - if (!( - is.logical(verbose) - && length(verbose) == 1 - )) { - if (verbose && cl) { - cat("\n") - cl <- FALSE - } - cli::cli_abort( - "{.var verbose} needs to be TRUE or FALSE." - ) - } else { - verbose <- verbose } if (verbose) {