data(uti)
dev.new()
uti2 <- within(uti,cd4C <- cut(log(cd4),4,labels=c("low","mid-low","mid-high","high")))
out <- aggregate(cbind(episodes,time) ~ cd4C, sum, data=uti2)
barplot(12*episodes/time ~ cd4C, beside=TRUE, data=out, col="red",
xlab="CD4+ cell count", ylab="Number of UTIs per year")
Run the code above in your browser using DataLab