View source: R/kpi_accumulate.R
kpi_accumulate | R Documentation |
kpi_accumulate
does this conversionAccumulate 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
kpi_accumulate(kpilist, by = NULL, split = TRUE)
kpilist |
list of KPIs |
by |
which |
split |
logical. Whether to split the output by the levels of the
|
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.