While this looks like a vctrs issue, I think it is actually a tibble issue
library(tidyverse)
t <- tibble(x=1,y=2)
tr <- tribble(~x, ~y,)
t %>% add_row(tr)
#> Error: Internal error in `vec_assign()`: `value` should have been recycled to fit `x`.
tr %>% add_row(t)
#> # A tibble: 1 x 2
#> x y
#> <dbl> <dbl>
#> 1 1 2
add_row() has this line that manually overwrites the row names
|
attr(df, "row.names") <- .set_row_names(max(1L, nrow(df))) |
vctrs uses this property to figure out the number of rows in the data frame, and with a 0-row data frame this line sets the number of rows to 1, which causes issues.
I think the purpose of this check is to ensure that add_row(df) adds a single row of missing values when the user hasn't provided any input, but there are other ways to get at that besides overwriting the row names attribute. I'll submit a PR with an alternative
Somewhat related commit 21541de
While this looks like a vctrs issue, I think it is actually a tibble issue
add_row()has this line that manually overwrites the row namestibble/R/add.R
Line 52 in b4eec19
vctrs uses this property to figure out the number of rows in the data frame, and with a 0-row data frame this line sets the number of rows to 1, which causes issues.
I think the purpose of this check is to ensure that
add_row(df)adds a single row of missing values when the user hasn't provided any input, but there are other ways to get at that besides overwriting the row names attribute. I'll submit a PR with an alternativeSomewhat related commit 21541de