From b3c7628fb00fdf70b098ffa9a4e73433e775a7f8 Mon Sep 17 00:00:00 2001 From: Daniel Date: Sun, 3 Mar 2024 20:15:53 +0100 Subject: [PATCH] test --- R/data_summary.R | 5 +++++ tests/testthat/test-data_summary.R | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/R/data_summary.R b/R/data_summary.R index 8bb4f3e09..3b02762ec 100644 --- a/R/data_summary.R +++ b/R/data_summary.R @@ -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) diff --git a/tests/testthat/test-data_summary.R b/tests/testthat/test-data_summary.R index e057cc35a..b82d78095 100644 --- a/tests/testthat/test-data_summary.R +++ b/tests/testthat/test-data_summary.R @@ -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" + ) })