Skip to content

Commit

Permalink
upload 06_combining_objects
Browse files Browse the repository at this point in the history
  • Loading branch information
kadyb committed Aug 8, 2023
1 parent c9014da commit 829c841
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions notebooks/06_combining_objects.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
title: "Fast combining objects"
output:
html_document:
df_print: paged
---

```{r message=FALSE}
library("sf")
library("data.table")
```

```{r}
nc = read_sf(system.file("shape/nc.shp", package = "sf"))
ls = vector("list", 500)
for (i in seq_along(ls)) ls[[i]] = nc
```

```{r}
system.time({
dt = rbindlist(ls, use.names = FALSE)
dt[["geometry"]] = st_sfc(dt[["geometry"]], recompute_bbox = TRUE)
dt = st_as_sf(dt)
})
```

```{r}
system.time({
df_sf = do.call(rbind, ls)
})
```

0 comments on commit 829c841

Please sign in to comment.