Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
strengejacke committed Mar 3, 2024
1 parent 973417b commit b3c7628
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions R/data_summary.R
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ data_summary.default <- function(x, ...) {
data_summary.data.frame <- function(x, ..., by = NULL) {
dots <- eval(substitute(alist(...)))

# do we have any expression at all?
if (length(dots) == 0) {
insight::format_error("No expressions for calculating summary statistics provided.")
}

if (is.null(by)) {
# when we have no grouping, just compute a one-row summary
summarise <- .process_datasummary_dots(dots, x)
Expand Down
5 changes: 5 additions & 0 deletions tests/testthat/test-data_summary.R
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,11 @@ test_that("data_summary, errors", {
data_summary(iris$Sepal.Width, MW = mean(Sepal.Width), SD = sd(Sepal.Width)),
regex = "only works for"
)
# no expressions
expect_error(
data_summary(iris, by = "Species"),
regex = "No expressions for calculating"
)
})


Expand Down

0 comments on commit b3c7628

Please sign in to comment.