If I perform an operation on an empty rowwise data frame, I would expect the result to be an empty data frame as well. Its similar to a for loop being skipped when the vector of indices is empty.
If I do this on a rowwise tibble with zero rows, it behaves as expected:
tibble(a = character(0)) %>%
rowwise() %>%
mutate(n = nchar(a)) %>%
{stopifnot(all.equal(.,
rowwise(tibble(a = character(0), n = integer(0))))}
This does not work for list columns
tibble(a = list()) %>%
rowwise() %>%
mutate(n = lengths(a))
Error: Problem with `mutate()` input `n`.
x subscript out of bounds
ℹ Input `n` is `lengths(a)`.
I would instead expect a return value like
rowwise(tibble(a = list(), n = integer()))
I tested this issue with dplyr, commit d56404c