Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

* Removed the `name` argument from the `compute()` generic (@ianmcook, #5783).

* row-wise data frames of 0 rows and list columns are supported again (#5804).

# dplyr 1.0.5

* Fixed edge case of `slice_sample()` when `weight_by=` is used and there
Expand Down
2 changes: 1 addition & 1 deletion R/data-mask.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ DataMask <- R6Class("DataMask",
public = list(
initialize = function(data, caller) {
rows <- group_rows(data)
# workaround for whene there are 0 groups
# workaround for when there are 0 groups
if (length(rows) == 0) {
rows <- list(integer())
}
Expand Down
2 changes: 1 addition & 1 deletion src/chop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ void dplyr_lazy_vec_chop_grouped(SEXP chops_env, SEXP rows, SEXP data, bool roww
SEXP prom = PROTECT(Rf_allocSExp(PROMSXP));
SET_PRENV(prom, R_EmptyEnv);
SEXP column = p_data[i];
if (rowwise && vctrs::vec_is_list(column)) {
if (rowwise && vctrs::vec_is_list(column) && Rf_length(column) > 0) {
SET_PRCODE(prom, column);
} else {
SET_PRCODE(prom, Rf_lang3(dplyr::functions::vec_chop, column, rows));
Expand Down
7 changes: 7 additions & 0 deletions tests/testthat/test-mutate.r
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,13 @@ test_that("can suppress or catch warnings from the outside (#5675)", {
}
})

test_that("mutate() supports empty list columns in rowwise data frames (#5804", {
res <- tibble(a = list()) %>%
rowwise() %>%
mutate(n = lengths(a))
expect_equal(res$n, integer())
})

# Error messages ----------------------------------------------------------

test_that("mutate() give meaningful errors", {
Expand Down