| as_sf | R Documentation |
Joins a sample, a frontier allocation or any data frame with a unit
column to the geometries of the sf object the frame came from, for maps.
as_sf(x, sf, unit = NULL)
x |
A data frame with a |
sf |
The |
unit |
Name of the column with the unit names in |
An sf object with the columns of x.
if (requireNamespace("sf", quietly = TRUE)) {
sq <- sf::st_sfc(sf::st_polygon(list(rbind(c(0, 0), c(0, 1), c(1, 1), c(1, 0), c(0, 0)))),
crs = 4326
)
cells <- sf::st_sf(geometry = sf::st_make_grid(sq, n = 4))
s <- select_units(as_frame(cells), n = 4, seed = 1)
as_sf(s, cells)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.