cf_pca: Calculate climate futures using PCA

Description Arguments Details Value Examples

View source: R/cf_pca.R

Description

Designates climate futures of "Warm Wet", "Warm Dry", "Hot Wet", "Hot Dry" and "Central" and calculates mean values for each GCM. Will additionally calculate which models represent the largest spread in data of variables entered using PCA. Calculates summary of threshold values based off of selected summarization parameter and PCA.

Arguments

SiteID

chosen name to use in file names, attributes, and directories. Default name is "unnamed_site" (character)

data

Default dataset to use for the .csv files this function will create. Follow vignette for example dataset creation. (data frame)

variables

Variables you want the PCA to be based off of. Must match column names from dataframe in data parameter exactly. If running directly from summarize_for_pca and would like to use all threshold values to select models, write "all_threshold" (character)

num_cf

Number of climate futures to select. Option of 2 or 4. Two models will be the maximum and minimum values of principal component 1 (PC1), and 4 will be the maximum and minimun values of principal component 2 (PC2)

directory

where to save files to. Per CRAN guidelines, this defaults to a temporary directory and files created will be lost after R session ends. Specify a path to retain files.

Details

*For advanced users only.

Value

One (1) csv file that has selected either 2 or 4 models, depending on num_cf chosen based upon PCA One (1) png file of the PCA scatterplot, with models labeled

Examples

 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
## Not run: 
# Generate sample data

data <- data.frame(
 gcm = c("bcc-csm1-1.rcp45", "BNU-ESM.rcp45", "CanESM2.rcp85", "CCSM4.rcp45",
             "CSIRO-Mk3-6-0.rcp45"),
 precip_change = rnorm(5),
 tmin_change = rnorm(5),
 tmax_change = rnorm(5),
 rhmax_change = rnorm(5),
 rhmin_change = rnorm(5),
 tavg_change = rnorm(5),
 heat_index_change = rnorm(5),
 heat_index_ec_change = rnorm(5),
 heat_index_dan_change = rnorm(5),
 temp_over_95_pctl_change =  rnorm(5),
 temp_over_99_pctl_change =  rnorm(5),
 temp_over_95_pctl_length_change =  rnorm(5),
 temp_under_freeze_change =  rnorm(5),
 temp_under_freeze_length_change =  rnorm(5),
 temp_under_5_pctl_change =  rnorm(5),
 no_precip_change  =  rnorm(5),
 no_precip_length_change =  rnorm(5),
 precip_95_pctl_change =  rnorm(5),
 precip_99_pctl_change =  rnorm(5),
 precip_moderate_change =  rnorm(5),
 precip_heavy_change =  rnorm(5),
 freeze_thaw_change =  rnorm(5),
 gdd_change =  rnorm(5),
 gdd_count_change = rnorm(5),
 not_gdd_count_change = rnorm(5),
 frost_change = rnorm(5),
 grow_length_change = rnorm(5),
 units = rep("imperial", each = 5)
)

cf_pca("SCBL", data = data, variables = c("tmin", "tmax", "rhmin"),
num_cf = 2)

## End(Not run)

nationalparkservice/rcf documentation built on Dec. 22, 2021, 12:01 a.m.