kpi_accumulate: Accumulate kpilists into KPIs per site lists The KPIs...

View source: R/kpi_accumulate.R

kpi_accumulateR Documentation

Accumulate kpilists into KPIs per site lists The KPIs themselves are all well and good for e.g. a report where you walk through each individual KPI and present all of the info there, but they're not ideal if you want all of the KPIs for a given site or country or the overall study in a single table. kpi_accumulate does this conversion

Description

Accumulate kpilists into KPIs per site lists The KPIs themselves are all well and good for e.g. a report where you walk through each individual KPI and present all of the info there, but they're not ideal if you want all of the KPIs for a given site or country or the overall study in a single table. kpi_accumulate does this conversion

Usage

kpi_accumulate(kpilist, by = NULL, split = TRUE)

Arguments

kpilist

list of KPIs

by

which by variable from the kpi call to accumulate

split

logical. Whether to split the output by the levels of the by variable(s)

Examples

kpi1 <- mtcars %>%
  kpi(var = "mpg", by = c("am", "cyl"), txt = "MPG",
      kpi_fn = kpi_fn_median, breakpoints = c(0, 20, 30, 50))
kpi2 <- mtcars %>%
  kpi(var = "drat", by = c("am", "cyl"), txt = "DRAT",
      kpi_fn = kpi_fn_median, breakpoints = c(0, 3, 4, 50))
l <- c(kpi1, kpi2)
kpi3 <- mtcars %>%
  mutate(cylgt4 = cyl > 4) %>%
  kpi(var = "cylgt4", by = c("am", "cyl"), txt = "Cylinders",
      kpi_fn = kpi_fn_perc, , breakpoints = c(0, 30, 50, 100))
l2 <- c(l, kpi3)
kpi_accumulate(l2)
# only the cyl level
kpi_accumulate(l2, by = "cyl")
# only the study/overall level
kpi_accumulate(l2, by = "overall")
# no splitting
kpi_accumulate(l2, split = FALSE)

CTU-Bern/kpitools documentation built on Aug. 19, 2024, 4:58 a.m.