This article provides examples and explanations of computations that can be done with this package.
In the previous articles we described how to get set up with all of the required datasets.
Setup
To start, we will load the package and create a variable that points to the data directory that we have set up.
library(champsmortality)
data_dir <- file.path(system.file(package = "champsmortality"), "testdata")
Note that this directory fully populated with synthetic data and comes with the package for the purposes of documentation and examples. This package is most useful with real data obtainable from CHAMPS. As such, keep in mind that the results of the examples in this documentation are not meaningful.
Read the data
We can read the all the datasets in and validate their structure with the following:
d <- read_and_validate_data(data_dir)
#> ✔ analytics_2022-05-24.csv
#> ✔ vocabulary_2022-05-24.csv
#> ✔ registry_2022-05-24.csv
#> ✔ dss_2022-05-24.csv
#> ✔ seasons.csv
#> ✔ catchment_lookup.csv
#> ✔ live_births.csv
#> ✔ dhs.csv
The validation ensures that all of the variables required to perform the calculations are present along with additional checks for the content of some of the variables. If there are any issues, you will see an error message and will need to correct the error before being able to use the package with your data.
Process the data
A function, process_data()
takes the data that has been read and joins it together to create a dataset ready for analysis.
dd <- process_data(d, start_year = 2017, end_year = 2020)
#>
#> ── processing analysis dataset ─────────────────────────────────────────────────
#> ✔ Calculated year of death from 'calc_dod'
#> ✔ Used CHAMPS vocabulary to transform 'age_group' in analysis dataset
#> ✔ Created a new variable 'age' that rolls up all neonates into one category to
#> be compatible with DSS data
#> ✔ Used CHAMPS vocabulary to transform 'calc_sex' in analysis dataset
#> ✔ Classified Verbal Autopsy Inter-VA Cause 1 codes as 'Infection', 'Trauma',
#> 'Other', or NA
#> ✔ Removed 2879 records that occur before 2017 or after 2020 or have a missing
#> date of death
#> ✔ Resolved catchment names from catchment IDs using catchment lookup table
#> ✔ Checked that values for 'catchment' in the analysis dataset are correct
#> ✔ Modified some analysis set variables to match what is found in DSS data:
#> • sex: set 'Indeterminate' and 'Unknown' to NA
#> • location: 'other' to NA
#> ✔ Checked that values for 'age' in the analysis dataset are correct
#> ✔ Checked that values for 'calc_sex' in the analysis dataset are correct
#> ✔ Checked that values for 'calc_location' in the analysis dataset are correct
#> ✔ Checked that values for 'va_cod_iva' in the analysis dataset are correct
#> ✔ Checked that values for 'site_name' in the seasons lookup are correct
#> ✔ Calculated season of death
#> ✔ Checked that values for 'season' in the seasons lookup are correct
#>
#> ── processing maternal registry ────────────────────────────────────────────────
#> ✔ Removed 244 records with missing 'champsid' from maternal registry dataset
#> ✔ The following 47 CHAMPS IDs have duplicate entries in the maternal registry
#> dataset and only the first record for each was kept: SEAA00272, SFAA00050,
#> SHAA00046, SHAA00052, SHAA00700, SHAA00882, SHAA00958, SHAA01135, SHAA01553,
#> SHAA01898, SHAA01935, SHAA02086, SHAA02123, SHCC00294, SIAA00004, SIAA00076,
#> SIAA00104, SIAA00327, SIAA00428, SIAA00518, SIAA00605, SIAA00851, SIAA00921,
#> SIAA00935, SIAA01277, SIAA01735, SIAA01841, SIAA01891, SOAA00370, SOAA00831,
#> SOAA00833, SOAA01383, SOCC00033, SOCC00043, SOCC00091, SOCC00207, SOCC00209,
#> SOCC00225, SOCC00236, SOCC00249, SOCC00308, SSAA00025, SSAA00267, SSAA00476,
#> SSAA01016, SSAA02207, STAA01650
#> ✔ Used CHAMPS vocabulary to transform 'education' in maternal registry dataset
#> ✔ Checked that values for 'education' in the maternal registry dataset are
#> correct
#> ✔ Joined analysis dataset and maternal registry
#>
#> ── checking live births ────────────────────────────────────────────────────────
#> ✔ Checked that values for 'site' in the live births data are correct
#> ✔ Checked that values for 'catchment' in the live births data are correct
#>
#> ── checking DHS data ───────────────────────────────────────────────────────────
#> ✔ Checked that values for 'site' in the DHS data are correct
#> ✔ Checked that values for 'catchment' in the DHS data are correct
#>
#> ── checking DSS ────────────────────────────────────────────────────────────────
#> ✔ Checked that values for 'site' in the DSS data are correct
#> ✔ Checked that values for 'catchment' in the DSS data are correct
#> ✔ Checked that values for 'age' in the DSS data are correct
#> ✔ Checked that values for 'level' in the DSS data are correct
#> ✔ Checked that values for 'level' in the DSS data are correct
#> ✔ Checked that values for 'level' in the DSS data are correct
#> ✔ Checked that values for 'level' in the DSS data are correct
#> ✔ Checked that values for 'va' in the DSS data are correct
Site and catchment listing
It is convenient to view a list of all sites and catchments that are available in the data. A simple utiltiy function, get_site_info()
can provide this:
get_site_info(dd)
#> # A tibble: 12 × 4
#> site catchment min_year max_year
#> <chr> <chr> <dbl> <dbl>
#> 1 S1 C11 2018 2020
#> 2 S2 C8 2017 2020
#> 3 S3 C10 2019 2020
#> 4 S3 C9 2017 2020
#> 5 S4 C12 2017 2020
#> 6 S5 C3 2019 2020
#> 7 S5 C4 2019 2020
#> 8 S5 C5 2019 2020
#> 9 S6 C1 2017 2020
#> 10 S6 C2 2018 2020
#> 11 S7 C6 2017 2020
#> 12 S7 C7 2017 2020
Valid conditions
Computations with this data have the goal of finding adjusted mortality fractions and rates for a given condition found in the causal chain. As you will see, these can be specified by either using the condition name or a regular expression indicating ICD10 codes that indicate the condition.
A convenience function that lists all available conditions in the data is provided, valid_conditions()
:
valid_conditions(dd)
#> # A tibble: 54 × 2
#> condition `causal chain rank`
#> <chr> <int>
#> 1 Perinatal asphyxia/hypoxia 1
#> 2 Neonatal preterm birth complications 2
#> 3 Lower respiratory infections 3
#> 4 Neonatal sepsis 4
#> 5 Sepsis 5
#> 6 Congenital birth defects 6
#> 7 Other neonatal disorders 7
#> 8 Malnutrition 8
#> 9 Meningitis/Encephalitis 9
#> 10 Malaria 10
#> # … with 44 more rows
This searches the CHAMPS data and finds all unique condition values found anywhere in the causal chain. A ranking is also provided where a higher ranking indicates that the condition is found more frequently in the data than a condition with a lower ranking.
Getting Rates and Fractions
The main function of this package computes factor-adjusted mortality rates and fractions for a specified set of sites and catchments. More details about the methodology can be found in this article.
The function is get_rates_and_fractions()
. It takes several parameters, many with defaults, and details about these parameters can be found in the function reference on this site. This article will cover many examples that illustrate all of the different ways this function can be used.
Below is a very simple example for getting rates and fractions for the condition “Lower respiratory infections”:
graf <- get_rates_and_fractions(
dd,
condition = "Lower respiratory infections",
cond_name_short = "LRI"
)
#> Processing site: S1
#> no adjustment variables
#> Processing site: S2
#> no adjustment variables
#> Processing site: S3
#> using adjustment variable: location
#> Processing site: S4
#> no adjustment variables
#> Processing site: S5
#> using adjustment variable: location
#> Processing site: S6
#> no adjustment variables
#> Processing site: S7
#> using adjustment variable: location
#> other significant factors not adjusted for: va
This applies the calculations to each site independently. For each site, data for all catchments are combined. To get results for individual catchments, you can call the function with specific catchments using the catchments
argument. The main arguments are the input data, dd
and the condition. Here we specify the optional parameter cond_name_short
to be “LRI”. This is used in some of the tabular and graphical outputs.
As seen in the printed output, some sites have no adjustment variables while others are adjusted on location. For site “S7”, both “location” and “va” were significant but we can only adjust for one variable or two variables if one of them is “age”, so just “location” is chosen.
Note: In the previous article’s discussion of the DSS data, we highlighted that because the data was collected in a way that crosses age with all of the other factors, but does not cross the other factors with each other, we can only adjust for one factor or age + another factor. If there are more than two candidate factors for adjustment, precedence is given to factors according to the following ranking:
- age
- season
- location
- va
- sex
- education
Examining the Output
The output of this function is a named list for each site, and contains many pieces of information for each site including underlying statistics that went into the calculations.
Note: Great care has gone into validating the outputs of the functions in this package, but we strongly encourage the user to examine the underlying statistics and assumptions to ensure the results are correct.
Let’s examine at a high level what is returned by this function for site S6:
str(graf$S6, max.level = 1, give.attr = FALSE)
#> List of 16
#> $ site : chr "S6"
#> $ catchments : chr [1:2] "C1" "C2"
#> $ inputs :List of 10
#> $ adjust_vars : NULL
#> $ mits : tibble [6 × 16] (S3: tbl_df/tbl/data.frame)
#> $ cond : tibble [6 × 10] (S3: tbl_df/tbl/data.frame)
#> $ pop_mits : tibble [1 × 3] (S3: tbl_df/tbl/data.frame)
#> $ crude_decoded : int 211
#> $ crude_condition : int 3
#> $ can_use_dss : logi FALSE
#> $ acMR_dss : num 574
#> $ acMR_dhs : num 340
#> $ frac : tibble [2 × 9] (S3: tbl_df/tbl/data.frame)
#> $ rate : tibble [2 × 8] (S3: tbl_df/tbl/data.frame)
#> $ rate_data :List of 6
#> $ rate_data_grouped:'data.frame': 1 obs. of 5 variables:
The first few elements are simply documenting the input parameters that went into the calculations. Specifically:
graf$S6$inputs
#> $condition
#> [1] "Lower respiratory infections"
#>
#> $icd10_regex
#> NULL
#>
#> $maternal
#> [1] FALSE
#>
#> $cond_name_short
#> [1] "LRI"
#>
#> $causal_chain
#> [1] TRUE
#>
#> $factor_groups
#> NULL
#>
#> $pval_cutoff
#> [1] 0.1
#>
#> $pct_na_cutoff
#> [1] 20
#>
#> $adjust_vars_override
#> NULL
#>
#> $per
#> [1] 10000
Many of these inputs are defaults that we didn’t specify.
The elements mits
and cond
are tables that capture information that is used in deciding whether any factors should be adjusted for. They contain one row for each factor, e.g.:
graf$S6$mits
#> # A tibble: 6 × 16
#> site catchment factor start…¹ end_y…² table pval n_dss na_dss n_mits
#> <chr> <chr> <fct> <dbl> <dbl> <list> <dbl> <dbl> <dbl> <int>
#> 1 S6 C1, C2 age 2017 2020 <tibble> 9.21e- 4 0 0 212
#> 2 S6 C1, C2 sex 2017 2020 <tibble> 4.89e- 1 0 0 211
#> 3 S6 C1, C2 educati… 2017 2020 <tibble> 9.56e- 1 0 0 89
#> 4 S6 C1, C2 season 2017 2020 <tibble> 1.08e- 2 0 0 212
#> 5 S6 C1, C2 location 2017 2020 <tibble> 2.57e-37 0 0 212
#> 6 S6 C1, C2 va 2017 2020 <tibble> 1.32e- 5 0 0 201
#> # … with 6 more variables: n_non_mits <int>, na_mits <int>, na_non_mits <int>,
#> # n_na <dbl>, n_tot <dbl>, pct_na <dbl>, and abbreviated variable names
#> # ¹start_year, ²end_year
Each row contains information that went into the calculation of whether the factor is statistically significantly associated with MITS consent.
The table
variable contains nested tables with additional details. For example, see the table associated with the factor age
:
graf$S6$mits$table[[1]]
#> # A tibble: 4 × 3
#> level MITS `non-MITS`
#> <fct> <dbl> <dbl>
#> 1 Stillbirth 106 393
#> 2 Neonate 93 376
#> 3 Infant 9 81
#> 4 Child 4 66
We see counts of MITS vs. non-MITS broken down by age. A chi-square test is carried out on this table to determine a p-value. If a factor is significant and has sufficiently non-missing data (default is 20%), it is a candidate for adjustment.
The pop_mits
element reports statistics of number of stillbirths and under-5 deaths plus stillbirths for each catchment in the site.
graf$S6$pop_mits
#> # A tibble: 1 × 3
#> site stillbirths u5d_sb
#> <chr> <dbl> <dbl>
#> 1 S6 499 1128
The output can_use_dss
specifies whether the site consists of all-DSS sites and helps determine how to combine statistics across sites, as described in more detail here.
The outputs acMR_*
provide the all-cause mortality rate from the DSS and DHS data sources that were used in the calculations.
The most interesting outputs are the rates and fractions:
graf$S6$rate
#> # A tibble: 2 × 8
#> site catchments var label allca…¹ est lower upper
#> <chr> <chr> <chr> <chr> <dbl> <dbl> <dbl> <dbl>
#> 1 S6 C1, C2 cTU5MR Crude total under-5 mortali… 457. 6.50 2.36 15.1
#> 2 S6 C1, C2 aTU5MR Adjusted total under-5 mort… 457. 6.50 2.36 15.1
#> # … with abbreviated variable name ¹allcauseMR
graf$S6$frac
#> # A tibble: 2 × 9
#> site catchments var label decode condi…¹ est lower upper
#> <chr> <chr> <chr> <chr> <int> <int> <dbl> <dbl> <dbl>
#> 1 S6 C1, C2 cCSMF Crude cause-specific … 211 3 1.42 0.515 3.30
#> 2 S6 C1, C2 aCSMF Adjusted cause-specif… 211 3 1.42 0.515 3.30
#> # … with abbreviated variable name ¹condition
The additional outputs rate_*
provide additional information about what went into the rate and fraction calculations.
Additional inputs to get_rates_and_fractions()
There are other noteworthy inputs to get_rates_and_fractions()
. For full documentation you can refer to the function reference on this site.
Suppose we want to calculate rates and fractions for just site “S6” for the condition malaria, not in the causal chain. In this case, we don’t want to consider data from stillbirths:
res <- get_rates_and_fractions(
dd,
sites = "S6",
causal_chain = FALSE,
condition = "Malaria",
factor_groups = list(age = list(
Neonate = "Neonate",
Infant = "Infant",
Child = "Child"
))
)
#> no adjustment variables
Here, to specify that we are not looking in the causal chain, we set causal_chain = FALSE
(default is TRUE
).
Recoding factor groups
To specify that we do not want to include stillbirths, in the previous example we provided an argument factor_groups
. This argument is taken as a named list, with each possible entry relating to one of the factors. Inside the list, a mapping can be made with the left-hand-side indicating the name of the new factor level and the right-hand-side indicating what levels of the original factor to include in that calculation.
For example, we could specify that we want to define a new breakdown of age with one category being “Infant” that includes “Neonate” and “Infant” and another, “Child” that maps to the existing category “Child”. Additionally, suppose we want to break education down into two groups, “Lower” - comprised of “None” and “Primary”, and “Upper” - comprised of “Secondary” and “Tertiary”. We could do this by specifying the following as the input for factor_groups
:
list(
age = list(
Infant = c("Neonate", "Infant"),
Child = "Child"
),
education = list(
"Lower" = c("None", "Primary"),
"Upper" = c("Secondary", "Tertiary")
)
)
#> $age
#> $age$Infant
#> [1] "Neonate" "Infant"
#>
#> $age$Child
#> [1] "Child"
#>
#>
#> $education
#> $education$Lower
#> [1] "None" "Primary"
#>
#> $education$Upper
#> [1] "Secondary" "Tertiary"
Such groupings can be useful if dealing with a condition that has very low counts.
If a category of one of the factors is not provided in the specification, cases with that factor level are excluded from the analysis. For example, in the previous examples, the calculations will not include stillbirths.
In this example, we are only looking at neonates:
npbc_cc <- get_rates_and_fractions(dd,
sites = "S1",
condition = "Neonatal preterm birth complications",
cond_name = "NPBC",
causal_chain = TRUE,
factor_groups = list(age = list(Neonate = "Neonate"))
)
#> no adjustment variables
Calculating for subset of sites and catchments
In the previous examples, results have been applied to all catchments within each site. If we wish to perform the initial analysis but only obtain estimates for one catchment, “C1” of site “S6”:
graf <- get_rates_and_fractions(
dd,
sites = "S6",
catchments = "C1",
condition = "Lower respiratory infections",
cond_name_short = "LRI"
)
#> no adjustment variables
Suppose we want to obtain results for just a subset of sites and catchments:
graf <- get_rates_and_fractions(
dd,
sites = c("S5", "S6"),
catchments = c("C1", "C4", "C5"),
condition = "Lower respiratory infections",
cond_name_short = "LRI"
)
#> Processing site: S5
#> ℹ The following catchments are not found in the data for site S5 and will be
#> removed from the calculations for this site: C1
#> using adjustment variable: location
#> Processing site: S6
#> ℹ The following catchments are not found in the data for site S6 and will be
#> removed from the calculations for this site: C4, C5
#> no adjustment variables
Overriding adjustment variables
Suppose you have calculated rates and fractions and examined the underlying data and determined that even though a factor wasn’t significant, it is close enough and you want to force the computations to adjust for the factor, you can use the adjust_vars_override
argument. For example, suppose we want to force one of our previous examples to adjust on “age” and “location”:
graf <- get_rates_and_fractions(
dd,
sites = "S6",
catchments = "C1",
condition = "Lower respiratory infections",
cond_name_short = "LRI",
adjust_vars_override = c("age", "location")
)
#> using override adjustment variables:age, location
Finer control over condition specification
Conditions can be specified by using a valid value from valid_conditions(dd)
or through a regular expression specifying ICD10 codes that define the condition, or both.
If causal_chain = TRUE
, the condition of ICD10 codes are checked against underlying, immediate, and morbid conditions. If FALSE
, just the underlying is checked.
For example, to get statistics for neural tube defects, we can specify a search for all cases with ICD10 codes that begin with “Q00”, “Q01”, or “Q05”. To specify this as a regular expression, we can provide a string “Q00|Q01|^Q05”. Here, “^” means “starts-with”, and “|” means “or”.
ntd_cc <- get_rates_and_fractions(
dd,
icd10_regex = "^Q00|^Q01|^Q05",
cond_name = "NTD+CBD"
)
#> Processing site: S1
#> no adjustment variables
#> Processing site: S2
#> no adjustment variables
#> Processing site: S3
#> no adjustment variables
#> Processing site: S4
#> no adjustment variables
#> Processing site: S5
#> no adjustment variables
#> Processing site: S6
#> no adjustment variables
#> Processing site: S7
#> no adjustment variables
If both condition
and icd10_regex
are provided, they are both searched for and all cases that meet either the condition or the ICD10 specification are included. So for example if we wanted to look at rates and fractions for cases where the underlying cause is either the condition “Congenital birth defects” or NTD, we can do the following:
ntd_cbd_cc <- get_rates_and_fractions(
dd,
condition = "Congenital birth defects",
icd10_regex = "^Q00|^Q01|^Q05",
cond_name = "NTD+CBD"
)
#> Processing site: S1
#> no adjustment variables
#> Processing site: S2
#> no adjustment variables
#> Processing site: S3
#> no adjustment variables
#> Processing site: S4
#> no adjustment variables
#> Processing site: S5
#> no adjustment variables
#> Processing site: S6
#> no adjustment variables
#> Processing site: S7
#> using adjustment variable: va
Note that you can also provide multiple conditions, in which case the calculation will be for cases that have any of the specified conditions:
sep_uc <- get_rates_and_fractions(
dd,
sites = "S1",
causal_chain = FALSE,
condition = c("Sepsis", "Neonatal sepsis"),
cond_name = "Sepsis"
)
#> no adjustment variables
Maternal conditions
We can also calculate rates and fractions for maternal conditions. A list of valid maternal conditions can be obtained with the following:
valid_maternal_conditions(dd)
#> # A tibble: 39 × 2
#> condition rank
#> <chr> <int>
#> 1 Maternal hypertension 1
#> 2 Placental complications 2
#> 3 Other labor and delivery complications 3
#> 4 Chorioamnionitis and membrane complications 4
#> 5 Obstructed labor and fetal malpresentation 5
#> 6 Other maternal factor 6
#> 7 Multiple gestation 7
#> 8 Umbilical cord complications 8
#> 9 Premature Rupture of membranes 9
#> 10 HIV 10
#> # … with 29 more rows
Suppose we want to calculate statistics for “Maternal hypertension”. To do this, we simply provide this as the condition
and specify maternal = TRUE
. This lets the function know to look in the maternal conditions. Note that in this case, the value of causal_chain
does not apply and is ignored.
htn_s1 <- get_rates_and_fractions(dd,
sites = "S1",
condition = "Maternal hypertension",
maternal = TRUE,
cond_name = "HTN"
)
#> no adjustment variables
Batch rates and fractions
In the case that you would like to compute rates and fractions for a large number of site/catchment/condition/etc. combinations, you can use a function batch_rates_and_fractions()
. This takes an input csv such as the following:
inputs_csv <- tempfile(fileext = ".csv")
writeLines(
c(
"site,catchment,age,condition,icd10_regex,causal_chain,maternal",
"S6,C1;C2,Neonate;Infant;Child,Perinatal asphyxia/hypoxia,,TRUE,FALSE",
"S6,C1,Stillbirth,Congenital birth defects,,FALSE,FALSE"
),
inputs_csv
)
This identifies two scenarios we want to run, the first being Perinatal asphyxia/hypoxia for age groups “Neonate”, “Infant”, and “Child” in the causal chain for site “S6” and only its catchments “C1” and “C2”. Note that when an input has multiple values, we concatenate them with a semicolon.
The function batch_rates_and_fractions()
takes these inputs and runs them through get_rates_and_fractions()
.
bat1 <- batch_rates_and_fractions(dd, inputs_csv)
#> no adjustment variables
#> no adjustment variables
The output is a list of results of the type we have seen previously.
The csv approach can be nice for succinctly identifying a large number of scenarios to run, particularly if we want to get rates and fractions for each individual catchment of several sites, or if we want to look at several conditions, such as the top 10.
inputs2 <- list(
list(
site = "S6",
catchment = c("C1", "C2"),
age = c("Neonate", "Infant", "Child"),
condition = "Perinatal asphyxia/hypoxia",
icd10_regex = NULL,
causal_chain = TRUE,
maternal = FALSE
),
list(
site = "S6",
catchment = "C1",
age = "Stillbirth",
condition = "Congenital birth defects",
icd10_regex = NULL,
causal_chain = FALSE,
maternal = FALSE
)
)
bat2 <- batch_rates_and_fractions(dd, inputs2)
#> no adjustment variables
#> no adjustment variables
A drawback of the batch processing approach is that we do not quite have full control over all input parameters, such as custom factor groupings, etc. One could write their own custom script to iterate through scenarios in the rare occasions that more detailed specification is required.
Postprocessing
After we have processed several scenarios, it can be useful to conslidate the output into a simple table with one row per scenario and all of the relevant statistics. This can be done with a function rates_fracs_to_df()
.
For example, to turn our previous batch processing result into a table, we can do the following
tbl <- rates_fracs_to_df(bat1)
dplyr::glimpse(tbl)
#> Rows: 2
#> Columns: 21
#> $ site <chr> "S6", "S6"
#> $ catchments <chr> "C1,C2", "C1"
#> $ age <chr> "Neonate,Infant,Child", "Stillbirth"
#> $ condition <chr> "Perinatal asphyxia/hypoxia", "Congenital birth defect…
#> $ cond_name_short <chr> "Perinatal asphyxia/hypoxia", "Congenital birth defect…
#> $ dss_only <lgl> FALSE, TRUE
#> $ DeCoDe <int> 105, 38
#> $ n <int> 79, 0
#> $ cCSMF <dbl> 75.2381, 0.0000
#> $ cCSMF_LL <dbl> 67.85097235, 0.00513981
#> $ cCSMF_UL <dbl> 81.610365, 4.897288
#> $ aCSMF <dbl> 75.2381, 0.0000
#> $ aCSMF_LL <dbl> 67.85097235, 0.00513981
#> $ aCSMF_UL <dbl> 81.610365, 4.897288
#> $ cCSMR <dbl> 251.481, 0.000
#> $ cCSMR_LL <dbl> 226.7897844, 0.0135382
#> $ cCSMR_UL <dbl> 272.7801, 12.8994
#> $ aCSMR <dbl> 251.481, 0.000
#> $ aCSMR_LL <dbl> 226.7897844, 0.0135382
#> $ aCSMR_UL <dbl> 272.7801, 12.8994
#> $ adj_factors <chr> "None", "None"
Note that in addition to results of batch processing, we can also apply this function to the results of get_rates_and_fractions()
.
For example, in our first example of this article, we calculated LRI statistics for every site and catchment and stored the result in an object named graf
.
We can consolidate this output with the following:
rates_fracs_to_df(graf)
#> # A tibble: 1 × 21
#> site catch…¹ age condi…² cond_…³ dss_o…⁴ DeCoDe n cCSMF cCSMF…⁵ cCSMF…⁶
#> <chr> <chr> <chr> <chr> <chr> <lgl> <int> <int> <dbl> <dbl> <dbl>
#> 1 S6 C1 Stil… Lower … LRI TRUE 83 3 3.61 1.32 8.25
#> # … with 10 more variables: aCSMF <dbl>, aCSMF_LL <dbl>, aCSMF_UL <dbl>,
#> # cCSMR <dbl>, cCSMR_LL <dbl>, cCSMR_UL <dbl>, aCSMR <dbl>, aCSMR_LL <dbl>,
#> # aCSMR_UL <dbl>, adj_factors <chr>, and abbreviated variable names
#> # ¹catchments, ²condition, ³cond_name_short, ⁴dss_only, ⁵cCSMF_LL, ⁶cCSMF_UL
Visual and Tabular Outputs
The next article provides examples functions available in this package for creating nicely-formatted tables and figures of the outputs we have learned to create in this article.