addSamplesToBg: Add Samples to Background

Description Usage Arguments Value Author(s) Examples

View source: R/addSamplesToBg.R

Description

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

Usage

1

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.

Author(s)

Sergio Vignali

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
# 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

Example output

   _____  ____   __  ___ __
  / ___/ / __ \ /  |/  // /_ __  __ ____   ___
  \__ \ / / / // /|_/ // __// / / // __ \ / _ \
 ___/ // /_/ // /  / // /_ / /_/ // / / //  __/
/____//_____//_/  /_/ \__/ \__,_//_/ /_/ \___/  version 1.1.3

To cite this package in publications type: citation("SDMtune").
Extracting predictor information for presence locations...
sh: 1: awk: Permission denied
sh: 1: awk: Permission denied
sh: 1: awk: Permission denied
sh: 1: awk: Permission denied
sh: 1: awk: Permission denied
sh: 1: awk: Permission denied
sh: 1: awk: Permission denied
sh: 1: awk: Permission denied
sh: 1: awk: Permission denied
Extracting predictor information for absence/background locations...
sh: 1: awk: Permission denied
sh: 1: awk: Permission denied
sh: 1: awk: Permission denied
sh: 1: awk: Permission denied
sh: 1: awk: Permission denied
sh: 1: awk: Permission denied
sh: 1: awk: Permission denied
sh: 1: awk: Permission denied
sh: 1: awk: Permission denied
Object of class SWD 

Species: Virtual species 
Presence locations: 400 
Absence locations: 5207 

Variables:
---------
Continuous: bio1 bio12 bio16 bio17 bio5 bio6 bio7 bio8 
Categorical: biome 
Object of class SWD 

Species: Virtual species 
Presence locations: 400 
Absence locations: 5400 

Variables:
---------
Continuous: bio1 bio12 bio16 bio17 bio5 bio6 bio7 bio8 
Categorical: biome 

SDMtune documentation built on July 17, 2021, 9:06 a.m.