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
Not sure whether to place issue here or at tibble, feel free to move.
I am aware that tibble::new_tibble() is for advanced "only for clean inputs" use, and also that there is perhaps some use for this when creating empty list columns, etc. However, found this a bit surprising. P.S. Context for this is that I wanted to start optimizing my code based on a recent post (https://www.tidyverse.org/blog/2023/04/performant-packages/). Thought I could insert an list(b = if(condition) "insertme") # else NULL => drop column b.
library(tibble)
library(dplyr)
#> #> Attaching package: 'dplyr'#> The following objects are masked from 'package:stats':#> #> filter, lag#> The following objects are masked from 'package:base':#> #> intersect, setdiff, setequal, unionx<-list(a=1, b=NULL) %>% tibble::new_tibble()
x#> # A tibble: 1 × 2#> a#> <dbl>#> 1 1
str(x)
#> tibble [1 × 2] (S3: tbl_df/tbl/data.frame)#> $ a: num 1#> $ b: NULLy<-tibble::tibble(a=1, b=NULL)
str(y)
#> tibble [1 × 1] (S3: tbl_df/tbl/data.frame)#> $ a: num 1## Errors with bind_rows() dplyr::bind_rows(x)
#> Error in `vec_rbind()`:#> ! Unexpected `NULL`.#> ℹ In file 'slice.c' at line 322.#> ℹ This is an internal error that was detected in the vctrs package.#> Please report it at <https://github.com/r-lib/vctrs/issues> with a reprex (<https://tidyverse.org/help/>) and the full backtrace.#> Backtrace:#> ▆#> 1. ├─dplyr::bind_rows(x)#> 2. │ └─vctrs::vec_rbind(!!!dots, .names_to = .id, .error_call = current_env())#> 3. └─rlang:::stop_internal_c_lib(...)#> 4. └─rlang::abort(message, call = call, .internal = TRUE, .frame = frame)
The text was updated successfully, but these errors were encountered:
sda030
changed the title
Hidden NULL-column creating problems
Hidden NULL-column from tibble::new_tibble() causes error in vctrs::vec_rbind()Apr 22, 2023
vec_rbind() detects that something is weird and errors (much better than a crash). It gives an "internal" error but that isn't too far off, because it really does mean something fairly low level and internal has gone wrong
I think you'd be happy with using vctrs::df_list() before new_tibble(). It recycles inputs and drops NULLs automatically, and is still very fast.
Not sure whether to place issue here or at tibble, feel free to move.
I am aware that tibble::new_tibble() is for advanced "only for clean inputs" use, and also that there is perhaps some use for this when creating empty list columns, etc. However, found this a bit surprising. P.S. Context for this is that I wanted to start optimizing my code based on a recent post (https://www.tidyverse.org/blog/2023/04/performant-packages/). Thought I could insert an
list(b = if(condition) "insertme") # else NULL => drop column b
.Created on 2023-04-22 with reprex v2.0.2
The text was updated successfully, but these errors were encountered: