| aoe_sample.aoe_border_result | R Documentation |
Sample points from an aoe_border_result with control over side and/or
core/halo balance.
## S3 method for class 'aoe_border_result'
aoe_sample(
x,
n = NULL,
ratio = NULL,
by = c("side", "class"),
replace = FALSE,
...
)
x |
An |
n |
Total number of points to sample. If |
ratio |
Named numeric vector specifying target proportions. Names
should match the side names used in |
by |
Character. What to stratify by:
|
replace |
Logical. Sample with replacement? Default is |
... |
Additional arguments (ignored). |
An aoe_border_result object containing the sampled points.
library(sf)
# Create a border line
border <- st_as_sf(
data.frame(id = 1),
geometry = st_sfc(st_linestring(matrix(
c(0, 0, 100, 100), ncol = 2, byrow = TRUE
))),
crs = 32631
)
# Create points
pts <- st_as_sf(
data.frame(id = 1:6),
geometry = st_sfc(
st_point(c(10, 20)),
st_point(c(30, 10)),
st_point(c(50, 80)),
st_point(c(80, 40)),
st_point(c(5, 5)),
st_point(c(95, 95))
),
crs = 32631
)
result <- aoe_border(pts, border, width = 20,
side_names = c("west", "east"))
# Equal sampling from each side
balanced <- aoe_sample(result, ratio = c(west = 0.5, east = 0.5))
# Sample by core/halo instead
by_class <- aoe_sample(result, ratio = c(core = 0.5, halo = 0.5),
by = "class")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.