block_sample: Selection of blocks in environmental space

View source: R/block_sample.R

block_sampleR Documentation

Selection of blocks in environmental space

Description

Select a user-defined number of blocks in environmental space to be used in further analysis to define sampling sites for a survey system.

Usage

block_sample(master, expected_blocks, selection_type = "uniform",
             replicates = 10, set_seed = 1)

Arguments

master

master_matrix object derived from the function prepare_master_matrix or a master_selection object derived from functions random_selection, uniformG_selection, or uniformE_selection.

expected_blocks

(numeric) number of blocks to be selected.

selection_type

(character) type of selection. Two options are available: "uniform" and "random". Default = "uniform".

replicates

(numeric) number of thinning replicates performed to select blocks uniformly. Default = 10.

set_seed

(numeric) integer value to specify a initial seed. Default = 1.

Details

When blocks in master are defined using the option "equal_points" (see make_blocks), "uniform" selection_type could result in blocks with high density per area being overlooked.

Value

An S3 object of class master_matrix or master_selection, containing the same elements found in the input object, with an additional column in the master_matrix data.frame containing a binary code for selected (1) and non-selected (0) blocks.

Examples

# Data
m_matrix <- read_master(system.file("extdata/m_matrix.rds",
                                    package = "biosurvey"))

# Making blocks for analysis
m_blocks <- make_blocks(m_matrix, variable_1 = "PC1",
                        variable_2 = "PC2", n_cols = 10, n_rows = 10,
                        block_type = "equal_area")

# Selecting blocks uniformly in E space
block_sel <- block_sample(m_blocks, expected_blocks = 10,
                          selection_type = "uniform")

head(block_sel$data_matrix)

claununez/biosurvey documentation built on April 25, 2024, 12:24 a.m.