Open bart1 opened 1 year ago
Same here with pckg_vrs
columns so it might be a wider problem:
Sys.setenv(LANGUAGE="en")
a=tibble::tibble(y=package_version("1.0.0"))
b=tibble::tibble(x=character(0))
dplyr::bind_rows(a, b)
#> Warning in y[bad] <- rep.int(list(integer()), length(bad)): number of items to
#> replace is not a multiple of replacement length
#> Error in `vec_rbind()`:
#> ! `c()` method returned a vector of unexpected size 3 instead of 1.
#> i In file 'c.c' at line 414.
#> i 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:
#> x
#> 1. +-dplyr::bind_rows(a, b)
#> 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)
Created on 2023-05-05 with reprex v2.0.2
Oddly, I don't get the Warning in y[bad]
output outside of reprex
.
Also seeing this, however for me it is caused by binding 2 tibbles where only 1 has a geometry column and either tibble is empty:
df1 <- tibble::tibble(
ref = c("143_2", "143_2", "143_2", "143_2", "143_2"),
block = c("206/3", "217/8", "206/3", "206/3", "217/8"),
date = structure(c(19448, 19449, 19449, 19450, 19451), class = "Date")
)
df2 <- tibble::tibble(
ref = character(0),
latitude = numeric(0),
longitude = numeric(0),
date = structure(numeric(0), class = "Date"),
geometry = sf::st_sfc(crs = 4326)
)
dplyr::bind_rows(df1, df2)
#> Error in `vec_rbind()`:
#> ! `c()` method returned a vector of unexpected size 6 instead of 5.
#> ℹ In file 'c.c' at line 412.
#> ℹ 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.
Created on 2023-07-21 by the reprex package (v2.0.0)
df1 <- tibble::tibble(
ref = c("143_2", "143_2", "143_2", "143_2", "143_2"),
block = c("206/3", "217/8", "206/3", "206/3", "217/8"),
date = structure(c(19448, 19449, 19449, 19450, 19451), class = "Date"),
geometry = sf::st_sfc(sf::st_polygon(), crs = 4326)
)
df2 <- tibble::tibble(
ref = character(0),
latitude = numeric(0),
longitude = numeric(0),
date = structure(numeric(0), class = "Date")
)
dplyr::bind_rows(df1, df2)
#> Error in `vec_rbind()`:
#> ! `c()` method returned a vector of unexpected size 7 instead of 5.
#> ℹ In file 'c.c' at line 412.
#> ℹ 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.
Created on 2023-07-21 by the reprex package (v2.0.0)
df1 <- tibble::tibble(
ref = c("143_2", "143_2", "143_2", "143_2", "143_2"),
block = c("206/3", "217/8", "206/3", "206/3", "217/8"),
date = structure(c(19448, 19449, 19449, 19450, 19451), class = "Date"),
geometry = sf::st_sfc(sf::st_polygon(), crs = 4326)
)
df2 <- tibble::tibble(
ref = character(0),
latitude = numeric(0),
longitude = numeric(0),
date = structure(numeric(0), class = "Date"),
geometry = sf::st_sfc(crs = 4326)
)
dplyr::bind_rows(df1, df2)
#> # A tibble: 5 × 6
#> ref block date geometry latitude longitude
#> <chr> <chr> <date> <POLYGON [°]> <dbl> <dbl>
#> 1 143_2 206/3 2023-04-01 EMPTY NA NA
#> 2 143_2 217/8 2023-04-02 EMPTY NA NA
#> 3 143_2 206/3 2023-04-02 EMPTY NA NA
#> 4 143_2 206/3 2023-04-03 EMPTY NA NA
#> 5 143_2 217/8 2023-04-04 EMPTY NA NA
Created on 2023-07-21 by the reprex package (v2.0.0)
I get this error when binding a tibble with some rows to a spatial data frame with 0 rows:
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, union
library(sf)
#> Linking to GEOS 3.11.0, GDAL 3.5.3, PROJ 9.1.0; sf_use_s2() is TRUE
dat <- tibble(x = 1:5, y = 11:15)
dat
#> # A tibble: 5 × 2
#> x y
#> <int> <int>
#> 1 1 11
#> 2 2 12
#> 3 3 13
#> 4 4 14
#> 5 5 15
dat_sf <- st_sf(geometry=st_sfc())
dat_sf
#> Simple feature collection with 0 features and 0 fields
#> Bounding box: xmin: NA ymin: NA xmax: NA ymax: NA
#> CRS: NA
#> [1] geometry
#> <0 rows> (or 0-length row.names)
bind_rows(dat, dat_sf)
#> Error in `vec_rbind()`:
#> ! `c()` method returned a vector of unexpected size 6 instead of 5.
#> ℹ In file 'c.c' at line 414.
#> ℹ 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.
bind_rows(dat_sf, dat)
#> Error in `vec_rbind()`:
#> ! `c()` method returned a vector of unexpected size 6 instead of 5.
#> ℹ In file 'c.c' at line 414.
#> ℹ 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.
bind_rows(dat_sf, dat_sf)
#> Simple feature collection with 0 features and 0 fields
#> Bounding box: xmin: NA ymin: NA xmax: NA ymax: NA
#> CRS: NA
#> [1] geometry
#> <0 rows> (or 0-length row.names)
bind_rows(dat, dat)
#> # A tibble: 10 × 2
#> x y
#> <int> <int>
#> 1 1 11
#> 2 2 12
#> 3 3 13
#> 4 4 14
#> 5 5 15
#> 6 1 11
#> 7 2 12
#> 8 3 13
#> 9 4 14
#> 10 5 15
Created on 2024-05-02 with reprex v2.1.0
I'm not sure if this is an error of the
vctrs
implementation insf
or a problem invtrcs
, as the suggestion is to report it here I'll do that first. The error occurs when0
rows are added to ansf
data.frame
(as part of code where the number of rows added is variable).Created on 2022-11-25 with reprex v2.0.2