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
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
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
tibble 3.0.4
- Establish compatibility with upcoming pillar 1.5.0 (#818).
- `tbl_sum()` shows "data frame" instead of "tibble" for objects inheriting from `"tbl"` but not `"tbl_df"` (#818).
- Export `format.tbl()` and `print.tbl()` only if pillar doesn't (#816).
- Use `vctrs::num_as_location()` internally for subset assignment of rows and columns for better error messages (#746).
- Adapt tests to the development version of testthat.
- Fix documentation link to `base::Extract`.
- `add_row(df)` adds an empty row again (#809, @DavisVaughan).
This old thread has been automatically locked. If you think you have found something related to this, please open a new issue and link to this old issue if necessary.
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
The text was updated successfully, but these errors were encountered: