Description Usage Arguments Value Author(s) See Also Examples
This function calculates age-standardized one-variable frequencies. A separate function is available to produce age-standardized 2x2 tables of two variables, which is probably more useful for typical analyses.
1 | ageStdFreqs(dat,agedist,age,var)
|
dat |
data frame used for the analysis |
agedist |
Age-specific standardized weights. See documentaion on ?nutweightlist for details |
age |
Character vector for your age at baseline variable. This could be "AGE_INT" or "AGE92M", etc. |
var |
Character vector for the variable for which you need frequencies |
Data frame including the raw frequencies and proportions, and a age-standardized proportion.
Maret Maliniak
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | df <- example.data
mytable <- ageStdFreqs(dat=df,
agedist="YEARS00",
age="age92m",
var="bmicat92")
# Run multiple frequencies using lapply()
manytables <- lapply(c("bmicat92","smoke92"),function(x){
ageStdFreqs(dat=df,
agedist="YEARS00",
age="age92m",
var=x)
})
# create a single table from the results
final.frequencies <- Reduce(function(x,y) rbind(x,y), manytables)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.