Learn R Programming

SDMtune (version 1.1.1)

addSamplesToBg: Add Samples to Background

Description

The function add the presence locations to the background. This is equivalent to the Maxent argument addsamplestobackground=true.

Usage

addSamplesToBg(x, all = FALSE)

Arguments

x

'>SWD object.

all

logical, if TRUE it adds all the presence locations even if already included in the background locations, default is FALSE. This is equivalent to the Maxent argument addallsamplestobackground=true.

Value

An object of class '>SWD.

Examples

Run this code
# NOT RUN {
# Acquire environmental variables
files <- list.files(path = file.path(system.file(package = "dismo"), "ex"),
                    pattern = "grd", full.names = TRUE)
predictors <- raster::stack(files)

# Prepare presence and background locations
p_coords <- virtualSp$presence
bg_coords <- virtualSp$background

# Create SWD object
data <- prepareSWD(species = "Virtual species", p = p_coords, a = bg_coords,
                   env = predictors, categorical = "biome")

# Add presence locations with values not included in the background to the
# background locations
new_data <- addSamplesToBg(data)
new_data

# Add all the presence locations to the background locations, even if they
# have values already included in the background
new_data <- addSamplesToBg(data, all = TRUE)
new_data
# }

Run the code above in your browser using DataLab