Description Usage Arguments Value Author(s) Examples
Examine summary statistics of matching variables to determine matching criteria
1 2 3 4 5 6 7 8 9 10 11 12 13 | choose_criteria(
matchingvars = NULL,
criteria_list = NULL,
k = 200,
plot_coverage = TRUE,
raster_template = NULL,
subset_in_target = TRUE,
subsetcells = NULL,
matchingvars_id = "cellnumbers",
subsetcells_id = "site_id",
matching_distance = 1,
...
)
|
matchingvars |
data frame created using |
criteria_list |
list of matching criteria to test in the |
k |
number of points to use to find solution using |
plot_coverage |
boolean. Indicates whether the algorithm should display a barplot of the coverage for each set of criteria. Default is TRUE. |
raster_template |
one of the raster layers used for input data.
See |
subset_in_target |
boolean. Indicates if Subset cells have been selected
from Target cells using |
subsetcells |
data frame. Passed to |
matchingvars_id |
character or numeric. Refers to the column in
|
subsetcells_id |
character or numeric, but must be composed of numbers
and convertable to numeric. Refers to the column in |
matching_distance |
Gives the maximum allowable matching quality value
(weighted Euclidean distance) between Target and Subset cells, when
|
... |
accepts additional parameters to |
The output from the choose_criteria
function is a named list where
the first item ('totalarea') reports the total area in km2 of the Target cells
and the second item ('solution_areas') reports the area represented
(Euclidean distance of weighted matching variables <= 1 between Target and
matched subset cells) for each set of matching criteria.
Rachel R. Renne
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | # Load targetcells data for Target Cells
data(targetcells)
# Create data frame of potential matching variables for Target Cells
allvars <- makeInputdata(targetcells)
# Restrict data to matching variables of interest
matchingvars <- allvars[,c("cellnumbers","x","y","bioclim_01","bioclim_04",
"bioclim_09","bioclim_12","bioclim_15","bioclim_18")]
# Create list of matching criteria to choose:
# Look at 2.5%, 5%, & 10% of range and standard deviation for each variable
range2.5pct <- apply(matchingvars[,4:ncol(matchingvars)],2,
function(x){(max(x)-min(x))*0.025})
range5pct <- apply(matchingvars[,4:ncol(matchingvars)],2,
function(x){(max(x)-min(x))*0.05})
range10pct <- apply(matchingvars[,4:ncol(matchingvars)],2,
function(x){(max(x)-min(x))*0.1})
stddev <- apply(matchingvars[,4:ncol(matchingvars)],2,sd)
# Create a list of criteria
criteria_list <- list(range2.5pct, range5pct, range10pct, stddev)
###################################
# First an example where subset_in_target = TRUE
# Compare coverage with various criteria
# Create raster_template
raster_template <- targetcells[[1]]
# Note: n_starts should be >= 10, it is 1 here to reduce run time.
results2 <- choose_criteria(matchingvars, criteria_list = criteria_list,
n_starts = 1, k = 200,
raster_template = raster_template,
subset_in_target = TRUE, plot_coverage = TRUE)
###################################
# Now an example where subset_in_target is FALSE
# Bring in Subset cell data
data(subsetcells)
# Remove duplicates (representing cells with same climate but different soils--
# we want to match on climate only)
subsetcells <- subsetcells[!duplicated(subsetcells$site_id),]
# Pull out matching variables only, with site_id that identifies unique climate
subsetcells <- subsetcells[,c("site_id","X_WGS84","Y_WGS84","bioclim_01",
"bioclim_04","bioclim_09","bioclim_12",
"bioclim_15","bioclim_18")]
# Ensure that site_id will be values unique to subsetcells
subsetcells$site_id <- paste0("00",subsetcells$site_id)
# Create raster_template
raster_template <- targetcells[[1]]
# Run choose_criteria function to evaluate different matching criteria
coverage <- choose_criteria(matchingvars = matchingvars,
criteria_list = criteria_list,
plot_coverage = TRUE,
raster_template = raster_template,
subset_in_target = FALSE,
subsetcells = subsetcells,
matchingvars_id = "cellnumbers",
subsetcells_id = "site_id")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.