metrics_bind {multilandr}R Documentation

Metric's data preparation

Description

Merge data.frame with metric's values with a data.frame with other data.

Usage

metrics_bind(
  x,
  data,
  raster = NULL,
  classes = NULL,
  radii = NULL,
  c_level = NULL,
  l_level = NULL,
  ext_raster = NULL,
  show_class_names = FALSE
)

Arguments

x

An object of class 'MultiLandMetrics' generated with mland_metrics().

data

A data.frame with data from each sampling point/site. See Details.

raster, ext_raster, classes, radii, l_level, c_level

Parameters to subset data.frame containing the metrics values. See Details.

show_class_names

Logical. If TRUE, classes names will be returned as the names of the classes previously provided (if so) when x was generated. Default FALSE.

Details

Merges data.frame with metrics values, contained in an object of class 'MultiLandMetrics' (returned by mland_metrics()) with a data.frame with other data for each site. In this way, the returned data.frame will be prepared for later statistical or visual analyses. The data.frame provided in data must have a column named "site" or "point_id", containing unique identifiers for each sampling site, which must match with the identifiers present in the data.frame contained in x (i.e. data.frame with metrics values for each site). If "site", the function will assume that the site names are provided as identifiers. If "point_id", the function will assume that point ids are being provided. In any case, these identifiers must match the site identifiers in x.

Argument raster, ext_raster, classes, radii, l_level and c_level can be defined to subset the data.frame contained in x. In each one of these, an all-positive or an all-negative vector can be passed, whether to include (all-postive) or exclude (all-negative) the elements to be taken into account for the subsetting:

Value

A data.frame equal to sampling data provided in data but with additional columns containing the values of the metrics for each sampling site.

See Also

mland_metrics()

Examples

# Get sites names from ed_metrics and creates ad-hoc data.frame with random values of
# "richness" (the response variable). Only for the purpose of this example
sites <- ed_metrics@points$name
sampling_data <- data.frame(site = rep(sites, each = 10),
                            richness = sample(1:500, 150))

# With no filters, all columns with all metrics at all spatial scales are added to
# the sampling data
new_data <- metrics_bind(ed_metrics, sampling_data)

# Subset for metrics of class "Forest", radius 5000 and metric "pland"
new_data <- metrics_bind(ed_metrics, sampling_data, show_class_names = TRUE,
                         classes = "Forest", radii = 3000, c_level = "pland")

# In this format, the data.frame can be passed to a fitting model
fit <- lm(richness ~ r1_Forest_pland_3000, data = new_data)

[Package multilandr version 1.0.0 Index]