reconhub / incidence

☣:chart_with_upwards_trend::chart_with_downwards_trend:☣ Compute and visualise incidence
https://reconhub.github.io/incidence
Other
58 stars 13 forks source link

Add group accessors #65

Closed zkamvar closed 5 years ago

zkamvar commented 6 years ago

The accessors group_names() and n_groups() have been added. These do what one would expect, and there is an additional replacement feature for group_names() that allows one to fix spelling errors:

library(incidence)
set.seed(9)
x   <- rpois(100, 10)
grp <- sample(c("child", "adult", "adlut"), 
              100, 
              prob = c(0.45, 0.45, 0.05), 
              replace = TRUE)
i   <- incidence(x, group = grp)
plot(i)

group_names(i)
#> [1] "adlut" "adult" "child"
group_names(i) <- c("adult", "adult", "child")
plot(i)

Created on 2018-09-12 by the reprex package (v0.2.0).