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

rbind errors on vctrs_rcrd objects #1924

Open
khusmann opened this issue Apr 8, 2024 · 0 comments
Open

rbind errors on vctrs_rcrd objects #1924

khusmann opened this issue Apr 8, 2024 · 0 comments

Comments

@khusmann
Copy link

khusmann commented Apr 8, 2024

vec_rbind() works fine, but base::rbind() fails because it relies on the ability to [<- out-of-index in order to grow the vctr.

Here's a MWE running v0.6.5:

library(tibble)
library(vctrs)

format.foo <- function(x, ...) {
  format(vec_data(x)$a)
}

x <- new_rcrd(list(a = c("foo", "bar"), b = c("baz", "bling")), class="foo")

vec_rbind(tibble(x), tibble(x))
#> # A tibble: 4 × 1
#>       x
#>   <foo>
#> 1   foo
#> 2   bar
#> 3   foo
#> 4   bar

rbind(tibble(x), tibble(x))
#> Error:
#> ! Can't assign to elements past the end.
#> ℹ Locations 3 and 4 don't exist.
#> ℹ There are only 2 elements.
#> Backtrace:
#>     ▆
#>  1. ├─base::rbind(tibble(x), tibble(x))
#>  2. │ └─base::rbind(deparse.level, ...)
#>  3. │   ├─base::`[<-`(`*tmp*`, ri, value = `<foo>`)
#>  4. │   └─vctrs:::`[<-.vctrs_rcrd`(`*tmp*`, ri, value = `<foo>`)
#>  5. │     └─vctrs::vec_assign(vec_data(x), i, vec_data(value))
#>  6. └─vctrs (local) `<fn>`()
#>  7.   └─vctrs:::stop_subscript_oob(...)
#>  8.     └─vctrs:::stop_subscript(...)
#>  9.       └─rlang::abort(...)

Created on 2024-04-08 with reprex v2.0.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