Skip to content

unite fails with internal error if the columns don't exist #1512

Closed
@jwilliman

Description

@jwilliman

While using tidyr::unite on a list of dataframes I came across the following error. I'm only reporting it because it asked me to!

The list of dataframes was messy, so I was looking for a way of combining columns that may or may not exist. I'd be happy for unite to throw a warning, or error, to tell me that there were no input columns selected.

tidyr::unite(mtcars, "hello", contains("missing_column"))
#> 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. ├─tidyr::unite(mtcars, "hello", contains("missing_column"))
#>  2. └─tidyr:::unite.data.frame(mtcars, "hello", contains("missing_column"))
#>  3.   └─tidyr:::df_append(after = after)
#>  4.     └─tidyr:::check_number_whole(after, min = 0L, max = n, .internal = TRUE)
#>  5.       └─tidyr:::.rlang_types_check_number(...)
#>  6.         └─tidyr (local) .stop(x, what, ...)
#>  7.           └─tidyr:::stop_input_type(...)
#>  8.             └─rlang::abort(message, ..., call = call, arg = arg)

Created on 2023-08-31 with reprex v2.0.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugan unexpected problem or unintended behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions