
Last chance! 50% off unlimited learning
Sale ends in
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)
formatCases function will return a data frame.
disease cases data set, usually a data.frame which contains age and sex and number of cases.
results from getBreaks
function.
if it contains multiple years, define which years will be included in.
if want to view the data set from a macro way, could aggregate the data set by age or sex or other variables.
Patrick Brown
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.
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)
Run the code above in your browser using DataLab