prepare_master_matrix: Prepare a base object to perform further analyses

Description Usage Arguments Details Value Examples

View source: R/master_matrix.R

Description

prepare an S3 object that will serve as the base to perform all further analyses. This object will contain geographic and environmental information that will be used to characterize the region of interest.

Usage

1
2
3
4
prepare_master_matrix(region, variables, mask = NULL,
                      preselected_sites = NULL, do_pca = FALSE,
                      center = TRUE, scale = FALSE,
                      variables_in_matrix = NULL, verbose = TRUE)

Arguments

region

SpatialPolygons* of the region of interest; for instance, a country, another type of administrative are, or a protected area.

variables

RasterStack or RasterBrick of environmental variables.

mask

(optional) SpatialPolygons* object to mask variables and reduce region to an area that is more relevant for analysis (e.g., only areas with natural vegetation cover). Default = NULL.

preselected_sites

data.frame containing sites that must be included in posterior selections of sites for the survey system. Columns must be: "Sites", "Longitude", "Latitude", in that order.

do_pca

(logical) whether or not to perform a principal component analysis. Default = FALSE.

center

(logical) whether or not to center variables. Argument to be passed to the function prcomp. Default = TRUE.

scale

(logical) whether or not to scale the variables. Recommended when variables are in different units. Argument to be passed to the function prcomp. Default = FALSE.

variables_in_matrix

(character) name of variables to include in matrix. If NULL (the default) all variables will be included.

verbose

(logical) whether or not to print messages about the process. Default = TRUE.

Details

This function helps in preparing all data as needed for further analyses aiming to define a survey sampling system considering geographic and environmental spaces in the region of interest.

If mask is defined all analyses will be restricted to such an area. If mask is not fully contained by region, the mask used for reducing variables, and returned as part of the S3 object (master_matrix) is the intersection between them.

If preselected_sites is defined, environmental values and, if do_pca = TRUE, principal components are added to such records. These records and their characteristics will be considered in further analyses.

Value

An S3 object of class master_matrix containing the following elements:

Examples

1
2
3
4
5
6
7
8
# Data
data("mx", package = "biosurvey")
variables <- raster::stack(system.file("extdata/variables.tif",
                                       package = "biosurvey"))

# Create master matrix object
m_matrix <- prepare_master_matrix(region = mx, variables = variables,
                                  do_pca = TRUE, center = TRUE, scale = TRUE)

biosurvey documentation built on Sept. 16, 2021, 1:07 a.m.