formatCases | R Documentation |
The formatCases funtion formats the case data set. Changes other formats of age and sex group to three columns: age, ageNumeric and sex.
formatCases(casedata, ageBreaks = NULL, years = NULL, aggregate.by = NULL)
casedata |
disease cases data set, usually a data.frame which contains age and sex and number of cases. |
ageBreaks |
results from |
years |
if it contains multiple years, define which years will be included in. |
aggregate.by |
if want to view the data set from a macro way, could aggregate the data set by age or sex or other variables. |
After using formatCases function, the age columns will change to a "character" column contains ages in cut
format, i.e [50,55), denotes age 50.
The cut breaks can be found from the breaks of the population data set or defined by user.
The original "age" column will changed to "ageNumeric" columns as factors.
The sex column will have two levels "M" and "F" as factors.
If "aggregate.by" is not NULL, the number of cases will be sum up by the groups defined in aggregate.by
argument.
formatCases function will return a data frame.
Patrick Brown
data('casedata')
data('popdata')
head(casedata)
caseformat <- formatCases(casedata, ageBreaks = getBreaks(names(popdata)))
head(caseformat)
caseformatagg <- formatCases(casedata, ageBreaks = getBreaks(names(popdata)),
aggregate.by=c("age", "sex"))
head(caseformatagg)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.