A graph to help visualize what factors are influencing the index. Produces a plotly graphic where the bars are the total score for the factor after modifying it based on exposure. Hover to see the name of the factor and value of the exposure multiplier. Facets are produced if there are multiple scenarios
Arguments
- vuln_df
the
vuln_df
element of the result fromcalc_vulnerability
with an added column for the scenario_name. See examples.- tax_grp
Taxonomic group
Examples
# load dplyr for dealing with nested lists in table
library(dplyr)
#>
#> Attaching package: ‘dplyr’
#> The following objects are masked from ‘package:stats’:
#>
#> filter, lag
#> The following objects are masked from ‘package:base’:
#>
#> intersect, setdiff, setequal, union
base_pth <- system.file("extdata", package = "ccviR")
# scenario names
scn_nms <- c("RCP 4.5", "RCP 8.5")
clim_vars <- get_clim_vars(file.path(base_pth, "clim_files/processed"), scn_nms)
spat_res <- analyze_spatial(
range_poly = sf::read_sf(file.path(base_pth, "rng_poly.shp"), agr = "constant"),
scale_poly = sf::read_sf(file.path(base_pth, "assess_poly.shp"), agr = "constant"),
clim_vars_lst = clim_vars,
hs_rast = terra::rast(c(file.path(base_pth, "rng_chg_45.tif"),
file.path(base_pth, "rng_chg_85.tif"))),
hs_rcl = matrix(c(-1, 0, 1, 1, 2, 3), ncol = 2),
scenario_names = scn_nms
)
#> Checking files
#> Preparing polygon 'Climate Data Extext'
#> Preparing polygon 'Assessment Area'
#> Preparing polygon 'Range'
#> Clipping 'Range' to 'Climate Data Extent'
#> Clipping 'Range' to 'Assessment Area'
#> Assessing local climate exposure
#> Assessing thermal & hydrological niches
#> Assessing modelled range response to climate change
#> Warning: More than 10% of the range change raster does not match the expected values.
#> Is the classification table correct?
#> Finalizing outputs
# vulnerability factor table with score 1 (somewhat increase vulnerability)
# for all factors
vuln <- make_vuln_df("test_species", val1 = 1, mig = 1)
vuln$Value1[vuln$Code == "D4"] <- 1
index_vuln <- calc_vulnerability(spat_res$spat_table, vuln, "Bird")
#> calculating vulnerability index RCP 4.5
#> finished vulnerability
#> calculating vulnerability index RCP 8.5
#> finished vulnerability
bind_rows(index_vuln$vuln_df %>% `names<-`(index_vuln$scenario_name),
.id = "scenario_name") %>%
plot_q_score(tax_grp = "Bird")