You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, I stumbled on this by mistake and thought I'd open a PR given the error message.
It seems that unite could make an assertion about the shape of its input to prevent this.
Brief description of the problem: unite encounters an internal error if the input data is empty.
library(tibble)
library(tidyr)
options(error=traceback)
tibble(x=NULL) %>% unite(col='tmp', everything())
#> Error in `df_append()`:#> ! `after` must be a whole number, not an integer `NA`.#> ℹ This is an internal error that was detected in the tidyr package.#> Please report it at <https://github.com/tidyverse/tidyr/issues> with a reprex#> (<https://tidyverse.org/help/>) and the full backtrace.#> Backtrace:#> ▆#> 1. ├─tibble(x = NULL) %>% unite(col = "tmp", everything())#> 2. ├─tidyr::unite(., col = "tmp", everything())#> 3. └─tidyr:::unite.data.frame(., col = "tmp", everything())#> 4. └─tidyr:::df_append(after = after)#> 5. └─tidyr:::check_number_whole(after, min = 0L, max = n, .internal = TRUE)#> 6. └─tidyr:::.rlang_types_check_number(...)#> 7. └─tidyr (local) .stop(x, what, ...)#> 8. └─tidyr:::stop_input_type(...)#> 9. └─rlang::abort(message, ..., call = call, arg = arg)
This actually works in the dev version of tidyr and gives
# A tibble: 0 × 1# ℹ 1 variable: tmp <chr>
unite() has a guarantee that it will always generate the col column, regardless of how many columns you provide it, and we uphold that now even in the empty data frame case
Hello, I stumbled on this by mistake and thought I'd open a PR given the error message.
It seems that
unite
could make an assertion about the shape of its input to prevent this.Brief description of the problem:
unite
encounters an internal error if the input data is empty.Created on 2024-09-25 with reprex v2.0.2
The text was updated successfully, but these errors were encountered: