O'Reilly logo

Practical Predictive Analytics by Ralph Winters

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Calculating the column means

For the following simulation section, we will need to supply the column means via a vector, so let's calculate them now and display them as a horizontal barchart. We will calculate the column means first for the diabetes positive group and then for the diabetes negative group. Finally, we will calculate the means for the total, although we will not use them in the next section:

means.pos = colMeans(PimaIndians[PimaIndians$diabetes =='pos',1:8],na.rm=TRUE) means.neg = colMeans(PimaIndians[PimaIndians$diabetes =='neg',1:8],na.rm=TRUE) means.all = colMeans(PimaIndians[,1:8],na.rm=TRUE) barplot(means.all[c(1,2,3,4,5,6,7,8)],cex.axis=.75,cex.names=.70,horiz=TRUE,space=0)  

The barplot below shows the calculated means ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required