Hi all,
I'd like to use the function get_summary_stats from the rstatix package and addapt it to use scientific notations.
This is the function from the package:
function (data, ..., type = c("full", "common", "robust", "five_number",
"mean_sd", "mean_se", "mean_ci", "median_iqr", "median_mad",
"quantile", "mean", "median", "min", "max"), show = NULL,
probs = seq(0, 1, 0.25))
{
type = match.arg(type)
if (is_grouped_df(data)) {
results <- data %>% doo(get_summary_stats, ..., type = type,
show = show, probs = probs)
return(results)
}
data <- data %>% select_numeric_columns()
vars <- data %>% get_selected_vars(...)
n.vars <- length(vars)
if (n.vars >= 1) {
data <- data %>% select(!!!syms(vars))
}
variable <- .value. <- NULL
data <- data %>% gather(key = "variable", value = ".value.") %>%
filter(!is.na(.value.)) %>% dplyr::mutate(variable = factor(.data$variable,
levels = vars)) %>% group_by(variable)
results <- switch(type, common = common_summary(data), robust = robust_summary(data),
five_number = five_number_summary(data), mean_sd = mean_sd(data),
mean_se = mean_se(data), mean_ci = mean_ci(data), median_iqr = median_iqr(data),
median_mad = median_mad(data), quantile = quantile_summary(data,
probs), mean = mean_(data), median = median_(data),
min = min_(data), max = max_(data), full_summary(data)) %>%
dplyr::ungroup() %>% dplyr::mutate_if(is.numeric, round,
digits = 3)
if (!is.null(show)) {
show <- unique(c("variable", "n", show))
results <- results %>% select(!!!syms(show))
}
results
}
I think I would need to modify the dplyr::mutate_if(is.numeric, round, digits = 3) section, but I have tried a few things and is not working.
Many thanks for any help!
Beatriz