sample_random: Randomly sample survey units

View source: R/sampling.R

sample_randomR Documentation

Randomly sample survey units

Description

sample_random() generates a simple random sample of a set of survey units.

Usage

sample_random(units, n = NULL, fraction = NULL, column = "sample")

Arguments

units

An sf object of survey units.

n

Number of units to sample. Either n or fraction must be set.

fraction

Fraction of units to sample.

column

Name of the column to be added. Default: "sample".

Value

units with an additional boolean column describing the sample.

Examples

library(magrittr)
library(ggplot2)

rpolygon() %>%
  quadrats(n = c(10, 10)) %>%
  sample_random(n = 50) %>%
  ggplot(aes(fill = sample)) + geom_sf()

joeroe/fieldwalkr documentation built on Feb. 17, 2024, 12:15 a.m.