Skip to contents

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.

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.

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.

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)
#>    Longitude Latitude Mean_temperature Max_temperature Min_temperature
#> 8  -117.0833 32.58333              170             266              71
#> 9  -116.9167 32.58333              169             293              59
#> 10 -116.7500 32.58333              165             318              44
#> 11 -116.5833 32.58333              153             326              23
#> 12 -116.4167 32.58333              146             329               9
#> 13 -116.2500 32.58333              148             333               7
#>    Annual_precipitation Prec_wettest_month Prec_driest_month       PC1
#> 8                   234                 46                 1 -1.752933
#> 9                   277                 52                 1 -1.728394
#> 10                  336                 64                 2 -1.696348
#> 11                  409                 78                 2 -1.845195
#> 12                  400                 76                 1 -2.063613
#> 13                  320                 60                 1 -2.181253
#>          PC2 Block Selected_blocks
#> 8  1.0409917     5               0
#> 9  0.5996405     5               0
#> 10 0.2890784     4               0
#> 11 0.4419228     4               0
#> 12 0.5029680     4               0
#> 13 0.3238374     4               0