# NOT RUN {
## Code to generate an aggregated dataset
##
data(infants)
##
infants$smoker <- as.numeric(infants$cignum > 0)
infants$teen <- as.numeric(infants$mage < 20)
infants$lowgain <- as.numeric(infants$gained < 20)
infants$early <- as.numeric(infants$weeks < 32)
infants$lbw <- as.numeric(infants$weight < 2500)
##
listAgg <- list(year=infants$year,
smoker=infants$smoker,
teen=infants$teen,
lowgain=infants$lowgain,
race=infants$race,
male=infants$male,
early=infants$early,
lbw=infants$lbw)
infantsAgg <- aggregate(rep(1, nrow(infants)), listAgg, FUN=sum)
names(infantsAgg)[ncol(infantsAgg)] <- "N"
infantsAgg$Y <- aggregate(infants$death, listAgg, FUN=sum)$x
# }
Run the code above in your browser using DataLab