ageStdFreqs: Age-standardized frequencies

Description Usage Arguments Value Author(s) See Also Examples

View source: R/ageStdFreqs.R

Description

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.

Usage

1
ageStdFreqs(dat,agedist,age,var)

Arguments

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

Value

Data frame including the raw frequencies and proportions, and a age-standardized proportion.

Author(s)

Maret Maliniak

See Also

weightlist ageStdCrossTab

Examples

 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)

buddha2490/BERG documentation built on Feb. 7, 2020, 6:01 p.m.