diff --git a/R/utils_dim_control_and_checks.R b/R/utils_dim_control_and_checks.R index 79128a7b..b32332fd 100644 --- a/R/utils_dim_control_and_checks.R +++ b/R/utils_dim_control_and_checks.R @@ -28,7 +28,8 @@ #' (`add_specific_value`) and rows (`keep_spec_rows`). Exploratory plots can be also appreciated with #' `explorative = TRUE`. #' -#' @return A modified `data.frame` and a plot if `exporative = TRUE`. +#' @return A modified `data.frame` and a plot if `explorative = TRUE`. If not interactive and `explorative = TRUE`, +#' a plot object is returned. #' #' @examples #' # real case scenario: trimming of variables with too many levels @@ -208,7 +209,10 @@ reduce_num_levels_in_df <- function(dt, mutate(!!sym(variable) := factor(!!sym(variable))) if (explorative) { - return(gg) + if (!interactive()) { # for testing + return(gg) + } + print(gg) } invisible(out) } diff --git a/man/reduce_num_levels_in_df.Rd b/man/reduce_num_levels_in_df.Rd index 7eccb8cf..c4b7c82e 100644 --- a/man/reduce_num_levels_in_df.Rd +++ b/man/reduce_num_levels_in_df.Rd @@ -40,7 +40,8 @@ from the least frequent levels.} \item{verbose}{(\code{logical(1)})\cr if \code{TRUE}, messages are printed.} } \value{ -A modified \code{data.frame} and a plot if \code{exporative = TRUE}. +A modified \code{data.frame} and a plot if \code{explorative = TRUE}. If not interactive and \code{explorative = TRUE}, +a plot object is returned. } \description{ \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#experimental}{\figure{lifecycle-experimental.svg}{options: alt='[Experimental]'}}}{\strong{[Experimental]}} diff --git a/vignettes/data_pre_processing.Rmd b/vignettes/data_pre_processing.Rmd index 9b7e6cd9..11c6bf25 100644 --- a/vignettes/data_pre_processing.Rmd +++ b/vignettes/data_pre_processing.Rmd @@ -21,10 +21,6 @@ library(random.cdisc.data) data("cadae") ``` -```{r} -# desc_ae <- Hmisc::describe(cadae) -# desc_ae$SEX -``` ## Reducing number of levels per variable