Created
July 28, 2023 13:24
-
-
Save arthurgailes/0c10a78b3ec78f73104f2f66ac815221 to your computer and use it in GitHub Desktop.
R: collapse and sf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# list and unlist an sf object | |
library(collapse) | |
library(sf) | |
library(testthat) | |
nc <- st_read(system.file("shape/nc.shp", package="sf")) | |
nc_list <- rsplit(nc, by = seq_len(nrow(nc))) | |
nc_collapse <- unlist2d(nc_list, idcols = FALSE, recursive = FALSE) |> | |
st_as_sf() | |
expect_equal(nc, nc_collapse) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment