Description Usage Arguments Value Examples
description...
1 2 | calculate_stratified_prevalence(data, stratify.vars, pops = NULL,
region.head = "region", conf.level = 0.95, scale = 1)
|
data |
A line list-type data frame (one line per case), including a column with the region in which the case occurred and columns with stratification variables. |
stratify.vars |
A vector of strings containing the names of the column specifying the stratification variables. These columns should be factors. |
pops |
A data frame containing one line per region/stratification variable combination in |
region.head |
A string containing the name of the column specifying the region for each case. |
conf.level |
Level of confidence interval required for prevalence estimates. |
scale |
Scaling with which to report prevalence (per head, per 100 000, etc.) |
A list containing 1) prevalence.list
, a list of data frames containing total population, number of cases and prevalence by region, for each unique combination of stratification variables. 2) stratification.levels
, a vector of the stratification levels, in the same order that the stratified prevalence data frames are presented.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | my.data <- data.frame( county.id = ceiling(3*runif(10)),
age = rlnorm(10),
sex = factor(floor(2*runif(10)), levels=c(0,1), labels=c("male", "female"))
)
my.data$age.group = floor(my.data$age)
my.populations <- my.data[!duplicated(my.data[,c(1,3,4)]),]
my.populations$population <- nrow(my.data) + ceiling(abs(rnorm(nrow(my.populations), 10, 5)))
# example without any population data
calculate_stratified_prevalence(my.data, stratify.vars=c("sex", "age.group"), region.head="county.id")
# example with stratified population data
calculate_stratified_prevalence(my.data, stratify.vars=c("sex", "age.group"), pops=my.populations, region.head="county.id")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.