Closed hadley closed 5 years ago
Just wondering: is this related to https://github.com/r-spatial/sf/issues/49 ?
Reproducible example that shows expected behaviour. My understanding is that changes are needed on the dplyr side to allow bind_rows.sf
similar to *_join.sf
functions: https://github.com/r-spatial/sf/blob/master/R/join.R
Reprex:
library(sf)
#> Linking to GEOS 3.5.1, GDAL 2.2.2, proj.4 4.9.2
suppressPackageStartupMessages(library(tidyverse))
nc = read_sf(system.file("shape/nc.shp", package = "sf"))
r1 = rbind(nc[1, ], nc[2, ])
r2 = bind_rows(nc[1, ], nc[2, ])
#> Warning in bind_rows_(x, .id): Vectorizing 'sfc_MULTIPOLYGON' elements may
#> not preserve their attributes
#> Warning in bind_rows_(x, .id): Vectorizing 'sfc_MULTIPOLYGON' elements may
#> not preserve their attributes
class(r2)
#> [1] "sf" "tbl_df" "tbl" "data.frame"
# unclass(r2) # what's in it (all necessary elements it seems - lots)
r2
#> Error in .subset2(x, i): attempt to select less than one element in get1index
Apologies if this is unrelated, will happily create a separate issue if that's more useful but this seemed related.
A few specific use cases here are:
And, more use cases are documented in #2584
If #3552 is superseded by this, please add the more informative error reporting as a feature request here.
bind_rows()
should follow the principles in vctrs so there's no need for a separate issue.
This old issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with reprex) and link to this issue. https://reprex.tidyverse.org/
And work more like
readr::read_csv()
and friends; i.e. it should always return, providing a data frame or problems if needed.