Learn R Programming

mopa (version 1.0.1)

biomat: Matrix with variables for modelling

Description

Prepares matrix with variables for modeling

Usage

biomat(data, varstack)

Arguments

data

Data frame with coordinates in the first two columns and presence/absence (1=presence, 0=absence) in the third column.

varstack

RasterStack of the variables from which values are extracted for each point in data.

Value

2D matrix with the dependent variable (presence/absence) in the first column and the independent variables (extracted from varstack) in the rest.

Examples

Run this code
# NOT RUN {
## Load climate data
destfile <- tempfile()
data.url <- "https://raw.githubusercontent.com/SantanderMetGroup/mopa/master/data/biostack.rda"
download.file(data.url, destfile)
load(destfile, verbose = TRUE)

## Load and prepare presence data
data(Oak_phylo2)
dfp <-cbind(Oak_phylo2[[1]], "pa"= rep(1,nrow(Oak_phylo2[[1]])))
dfa <-cbind(Oak_phylo2[[2]], "pa"= rep(0,nrow(Oak_phylo2[[2]])))
df3 <-rbind(dfp, dfa)

## Build the data matrix for modeling
mat <-biomat(df3, biostack$baseline)
str(mat)

# }

Run the code above in your browser using DataLab