Learn R Programming

prioritizr (version 3.0.4)

add_relative_targets: Add Relative Targets

Description

Set targets as a proportion (between 0 and 1) of the maximum level of representation of features in the study area. The argument to x should have a single value if all features have the same target. Otherwise, the vector should have a value for each feature. In this case, targets are assigned to features based on their position in the argument to x and the feature when specifying the problem.

Usage

# S4 method for ConservationProblem,numeric
add_relative_targets(x, targets, ...)

# S4 method for ConservationProblem,character add_relative_targets(x, targets, ...)

Arguments

targets

numeric targets for features. If all features should have the same target, targets can be a single number. Otherwise, targets should be a numeric vector specifying a target for each feature. Alternatively, if the features in x were specified using a data.frame object, then argument to targets may refer to a column name.

...

not used.

Value

ConservationProblem-class object with the target added to it.

Details

Note that with the exception of the maximum cover problem, targets must be added to a problem or solving will return an error.

Targets are used to specify the minimum amount or proportion of a feature's distribution that needs to be protected. All conservation planning problems require adding targets with the exception of the maximum cover problem (see add_max_cover_objective), which maximizes all features in the solution and therefore does not require targets.

See Also

targets.

Examples

Run this code
# NOT RUN {
# load data
data(sim_pu_raster, sim_features)

# create base problem
p <- problem(sim_pu_raster, sim_features) %>%
     add_min_set_objective() %>%
     add_binary_decisions()

# create problem with 10 % targets
p1 <- p %>% add_relative_targets(0.1)

# create problem with varying targets for each feature
targets <- c(0.1, 0.2, 0.3, 0.4, 0.5)
p2 <- p %>% add_relative_targets(targets)
# }
# NOT RUN {
# solve problem
s <- stack(solve(p1), solve(p2))

# plot solution
plot(s, main = c("10 % targets", "varying targets"), axes = FALSE,
     box = FALSE)
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab