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

match(<num>, <num>) fails on R 4.3.0. #1542

Open
teunbrand opened this issue May 2, 2023 · 0 comments
Open

match(<num>, <num>) fails on R 4.3.0. #1542

teunbrand opened this issue May 2, 2023 · 0 comments

Comments

@teunbrand
Copy link

I'm propagating this issue from tidyverse/ggplot2#5284

I'd expected that the code below would work similarly as it does for numeric classes.

x <- tibble::num(c(0.001, 0.005))

# Expected output
vctrs::vec_match(x, x)
#> [1] 1 2

# This bug
match(x, x)
#> Error in `as.character()`:
#> ! Can't convert `x` <pillar_num> to <character>.
#> Backtrace:
#>      ▆
#>   1. ├─base::match(x, x)
#>   2. │ ├─base::mtfrm(`<num>`)
#>   3. │ └─base::mtfrm.default(`<num>`)
#>   4. │   ├─base::as.character(x)
#>   5. │   └─vctrs:::as.character.vctrs_vctr(x)
#>   6. │     └─vctrs::vec_cast(x, character())
#>   7. └─vctrs (local) `<fn>`()
#>   8.   └─vctrs::vec_default_cast(...)
#>   9.     ├─base::withRestarts(...)
#>  10.     │ └─base (local) withOneRestart(expr, restarts[[1L]])
#>  11.     │   └─base (local) doWithOneRestart(return(expr), restart)
#>  12.     └─vctrs::stop_incompatible_cast(...)
#>  13.       └─vctrs::stop_incompatible_type(...)
#>  14.         └─vctrs:::stop_incompatible(...)
#>  15.           └─vctrs:::stop_vctrs(...)
#>  16.             └─rlang::abort(message, class = c(class, "vctrs_error"), ..., call = call)

Created on 2023-05-02 with reprex v2.0.2

Created on 2023-05-02 with reprex v2.0.2

I think the culprit is base::mtfrm.default which uses as.character() in the new R version, whereas it used as.vector() in older versions (e.g. 4.2.2).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant