The function add the presence locations to the background. This is equivalent
to the Maxent argument addsamplestobackground=true.
Arguments
- x
- SWD object. 
- all
- logical. If - TRUEit adds all the presence locations even if already included in the background locations. This is equivalent to the Maxent argument- addallsamplestobackground=true.
Value
An object of class SWD.
Examples
# Acquire environmental variables
files <- list.files(path = file.path(system.file(package = "dismo"), "ex"),
                    pattern = "grd",
                    full.names = TRUE)
predictors <- terra::rast(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")
#> ℹ Extracting predictor information for presence locations
#> ✔ Extracting predictor information for presence locations [20ms]
#> 
#> ℹ Extracting predictor information for absence/background locations
#> ✔ Extracting predictor information for absence/background locations [47ms]
#> 
data
#> 
#> ── Object of class: <SWD> ──
#> 
#> ── Info 
#> • Species: Virtual species
#> • Presence locations: 400
#> • Absence locations: 5000
#> 
#> ── Variables 
#> • Continuous: "bio1", "bio12", "bio16", "bio17", "bio5", "bio6", "bio7", and
#> "bio8"
#> • Categorical: "biome"
# Add presence locations with values not included in the backgrounds to the
# background locations
new_data <- addSamplesToBg(data)
new_data
#> 
#> ── Object of class: <SWD> ──
#> 
#> ── Info 
#> • Species: Virtual species
#> • Presence locations: 400
#> • Absence locations: 5207
#> 
#> ── Variables 
#> • Continuous: "bio1", "bio12", "bio16", "bio17", "bio5", "bio6", "bio7", and
#> "bio8"
#> • Categorical: "biome"
# Add all the presence locations to the background locations, even if they
# have values already included in the backgrounds
new_data <- addSamplesToBg(data,
                           all = TRUE)
new_data
#> 
#> ── Object of class: <SWD> ──
#> 
#> ── Info 
#> • Species: Virtual species
#> • Presence locations: 400
#> • Absence locations: 5400
#> 
#> ── Variables 
#> • Continuous: "bio1", "bio12", "bio16", "bio17", "bio5", "bio6", "bio7", and
#> "bio8"
#> • Categorical: "biome"
