Generate a Summary data.frame for use in reports
Source:R/util-MakeMetricTable.R
MakeMetricTable.Rd
`r lifecycle::badge("stable")`
Generate a summary table for a report by joining the provided results data frame with the site-level metadata from dfGroups, and filter and arrange the data based on provided conditions.
Arguments
- dfResults
`r gloss_param("dfResults")` `r gloss_extra("dfResults_filtered")`
- dfGroups
`data.frame` Group-level metadata dictionary. Created by passing CTMS site and study data to [MakeLongMeta()]. Expected columns: `GroupID`, `GroupLevel`, `Param`, `Value`.
- strGroupLevel
group level for the table
- strGroupDetailsParams
one or more parameters from dfGroups to be added as columns in the table
- vFlags
`integer` List of flag values to include in output table. Default: `c(-2, -1, 1, 2)`.
Examples
# site-level report
MakeMetricTable(
dfResults = gsm.core::reportingResults %>%
dplyr::filter(.data$MetricID == "Analysis_kri0001") %>%
FilterByLatestSnapshotDate(),
dfGroups = gsm.core::reportingGroups
)
#> StudyID GroupID MetricID Group SnapshotDate Enrolled
#> 1 AA-AA-000-0000 0X2649 Analysis_kri0001 0X2649 (Deer) 2025-04-01 4
#> 2 AA-AA-000-0000 0X1750 Analysis_kri0001 0X1750 (Smith) 2025-04-01 7
#> 3 AA-AA-000-0000 0X6073 Analysis_kri0001 0X6073 (Smith) 2025-04-01 5
#> 4 AA-AA-000-0000 0X8764 Analysis_kri0001 0X8764 (Smith) 2025-04-01 7
#> 5 AA-AA-000-0000 0X759 Analysis_kri0001 0X759 (Smith) 2025-04-01 7
#> 6 AA-AA-000-0000 0X1982 Analysis_kri0001 0X1982 (Smith) 2025-04-01 7
#> 7 AA-AA-000-0000 0X9069 Analysis_kri0001 0X9069 (Deer) 2025-04-01 7
#> 8 AA-AA-000-0000 0X3289 Analysis_kri0001 0X3289 (Deer) 2025-04-01 5
#> 9 AA-AA-000-0000 0X8792 Analysis_kri0001 0X8792 (Smith) 2025-04-01 7
#> 10 AA-AA-000-0000 0X8609 Analysis_kri0001 0X8609 (Doe) 2025-04-01 4
#> 11 AA-AA-000-0000 0X4959 Analysis_kri0001 0X4959 (Doe) 2025-04-01 6
#> 12 AA-AA-000-0000 0X474 Analysis_kri0001 0X474 (Doe) 2025-04-01 3
#> Numerator Denominator Metric Score Flag
#> 1 19 102 0.19 2.42 1
#> 2 39 289 0.13 2.06 1
#> 3 1 133 0.01 -2.00 -1
#> 4 14 305 0.05 -1.48 -1
#> 5 14 303 0.05 -1.46 -1
#> 6 19 345 0.06 -1.18 -1
#> 7 9 192 0.05 -1.14 -1
#> 8 13 251 0.05 -1.13 -1
#> 9 15 280 0.05 -1.12 -1
#> 10 2 72 0.03 -1.07 -1
#> 11 16 285 0.06 -1.03 -1
#> 12 4 102 0.04 -1.01 -1