# Chi-Squared test for age of children in dp.ex02 sample dataset using an
# u5mr of 1 / 10,000 / day.
svy <- dp.ex02
ac <- ageChildren(svy$age, u5mr = 1)
ac
# Apply function to each sex separately
# Males
acM <- ageChildren(svy$age[svy$sex == 1], u5mr = 1)
acM
# Females
acF <- ageChildren(svy$age[svy$sex == 2], u5mr = 1)
# Simplified call to function by sex
by(svy$age, svy$sex, ageChildren, u5mr = 1)
Run the code above in your browser using DataLab