Skip to content

Commit

Permalink
Update data_summary.R
Browse files Browse the repository at this point in the history
  • Loading branch information
strengejacke committed Mar 3, 2024
1 parent 410090e commit 26f70f2
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions R/data_summary.R
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ data_summary.data.frame <- function(x, ..., by = NULL, include_na = TRUE) {
# bind grouping-variables and values
summarised_data <- cbind(s[1, by], summarised_data)
# make sure we have proper column names
colnames(summarised_data) <- c(by, vapply(summarise, names, character(1)))
colnames(summarised_data) <- c(by, unlist(lapply(summarise, names)))
summarised_data
})
out <- do.call(rbind, out)
Expand Down Expand Up @@ -170,7 +170,11 @@ data_summary.grouped_df <- function(x, ..., by = NULL, include_na = TRUE) {

out <- lapply(seq_along(dots), function(i) {
new_variable <- .get_new_dots_variable(dots, i, data)
stats::setNames(new_variable, names(dots)[i])
if (inherits(new_variable, c("bayestestR_ci", "bayestestR_eti"))) {
stats::setNames(new_variable, c("CI", "CI_low", "CI_high"))

Check warning on line 174 in R/data_summary.R

View check run for this annotation

Codecov / codecov/patch

R/data_summary.R#L174

Added line #L174 was not covered by tests
} else {
stats::setNames(new_variable, names(dots)[i])
}
})
}

Expand All @@ -185,6 +189,11 @@ print.dw_data_summary <- function(x, ...) {
if (nrow(x) == 0) {
cat("No matches found.\n")

Check warning on line 190 in R/data_summary.R

View check run for this annotation

Codecov / codecov/patch

R/data_summary.R#L190

Added line #L190 was not covered by tests
} else {
if (all(c("CI", "CI_low", "CI_high") %in% colnames(x))) {
ci <- insight::format_table(x[c("CI", "CI_low", "CI_high")], ...)
x$CI <- x$CI_low <- x$CI_high <- NULL
x <- cbind(x, ci)

Check warning on line 195 in R/data_summary.R

View check run for this annotation

Codecov / codecov/patch

R/data_summary.R#L193-L195

Added lines #L193 - L195 were not covered by tests
}
cat(insight::export_table(x, missing = "<NA>", ...))
}
}

0 comments on commit 26f70f2

Please sign in to comment.