biomat: Matrix with variables for modelling

Description Usage Arguments Value Author(s) Examples

View source: R/biomat.R

Description

Prepares matrix with variables for modeling

Usage

1
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.

Author(s)

M. Iturbide

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
## 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)

mopa documentation built on May 2, 2019, 6:47 a.m.