vctrs
vctrs copied to clipboard
`vec_rbind` with `.id` parameter sometimes assigns class `common_class_fallback` to last column
For certain input data types (but not all) if vec_rbind
is called with a value for the .id
parameter, then the last column is assigned the class vctrs:::common_class_fallback
instead of the class of the input columns. For example:
library(tibble) # tibble_3.1.2
library(vctrs) # vctrs_0.3.8
library(zoo) # zoo_1.8-9
vec_rbind(tibble(q = as.yearqtr('2000q1')), tibble(q = as.yearqtr('2000q2'))) # Ok
vec_rbind(tibble(q = as.yearqtr('2000q1')), tibble(q = as.yearqtr('2000q2')), .names_to = "id") # Problem
vec_rbind(tibble(q = as.yearqtr('2000q1'), r = 1), tibble(q = as.yearqtr('2000q2'), r = 1), .names_to = "id") # Ok
# "Ok" means column q has class yearqtr; "Problem" means it does not
This was noticed because the problem shows up in dplyr::bind_rows()
: SO question about bind_rows(..., .id)
.