Learn R Programming

agricolaeplotr (version 0.6.1)

sample_locations: Sample Locations

Description

Returns locations to sample for each plot.

Usage

sample_locations(design, n, plot = TRUE, ...)

Value

An `sf` object containing the sample locations within each plot.

Arguments

design

Your experiment design of plot layouts.

n

Number of samples per plot (integer).

plot

Logical, indicating whether to visualize the sample locations as a ggplot2-based map.

...

further options for `st_sample` and `make_polygons`

Details

This function takes an experiment design (plot layout) and returns random sample locations within each plot. The function uses the `sf` package to generate spatial polygons for the plots and then samples points within each polygon. Optionally, it can also display the sample locations as a ggplot2-based map.

Examples

Run this code
library(agricolaeplotr)
library(agricolae)
library(ggplot2)
trt <- c('A', 'B', 'C', 'D')
k <- 3
outdesign <- design.bib(trt, k, serie = 2, seed = 41, kinds = 'Super-Duper')
plot_bib(outdesign)
p <- plot_bib(outdesign)
sample_locations(p, 3, TRUE, projection_output = 25832)

Run the code above in your browser using DataLab