Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
jwilliman opened this issue Aug 31, 2023 · 3 comments
Open

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

jwilliman opened this issue Aug 31, 2023 · 3 comments
Labels
bug an unexpected problem or unintended behavior

Comments

@jwilliman
Copy link

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

@DavisVaughan
Copy link
Member

I think its a bug on our end, thanks!

@DavisVaughan DavisVaughan added the bug an unexpected problem or unintended behavior label Aug 31, 2023
@GuiFabre
Copy link

Hello, I get the same error. Not to mention that the error is not consistent. Sometimes it works, sometimes not.

The problem might come from the fact it use unite( -1 , [...] ) instead of unite( 2:last_col() , [...] ) or something.

Best :

image

@jospueyo
Copy link

Same error here. I came because the error told me to do so.

library(tidyverse)

df <- tibble(
  a_1 = 3,
  a_2 = 4
)

df |> 
  unite(b, starts_with("b"))
#> 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(df, b, starts_with("b"))
#>  2. └─tidyr:::unite.data.frame(df, b, starts_with("b"))
#>  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 2024-02-12 with reprex v2.0.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

4 participants