Skip to content

Commit

Permalink
Merge pull request #825 from markfairbanks/empty-dt
Browse files Browse the repository at this point in the history
Allow empty `dt()` with no warning
  • Loading branch information
markfairbanks authored Sep 25, 2024
2 parents 1ccf1c3 + af57a60 commit 33afeb4
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# tidytable 0.11.2 (in development)

#### Bug fixes
* `dt()` works with no warning, #824

# tidytable 0.11.1

#### Functionality improvements
Expand Down
2 changes: 1 addition & 1 deletion R/dt.R
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ dt <- function(.df, i, j, ...) {
dt.tidytable <- function(.df, i, j, ...) {
args <- enquos(i, j, ..., .unquote_names = FALSE, .ignore_empty = "none")

if (has_length(args, 0)) return(.df)
if (all(map_lgl(args, quo_is_missing))) return(.df)

dt_env <- get_dt_env(args)

Expand Down
6 changes: 6 additions & 0 deletions tests/testthat/test-dt.R
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,9 @@ test_that("let works", {
expect_named(res, c("x", "double_x"))
expect_equal(res$double_x, c(2, 2, 2))
})

test_that("no warning on empty dt, #824", {
df <- tidytable(x = c(1, 1, 1), y = 1:3)

expect_no_warning(df %>% dt())
})

0 comments on commit 33afeb4

Please sign in to comment.