Skip to Content
Practical Predictive Analytics
book

Practical Predictive Analytics

by Ralph Winters
June 2017
Beginner to intermediate
576 pages
15h 22m
English
Packt Publishing
Content preview from Practical Predictive Analytics

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 ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Data Superstream: Analytics Engineering

Data Superstream: Analytics Engineering

Alistair Croll, Anna Filippova, Emilie Schario, Lewis Davies, Jacob Frackson, Benn Stancil, Nick Acosta, Elizabeth Caley
R: Predictive Analysis

R: Predictive Analysis

Tony Fischetti, Eric Mayor, Rui Miguel Forte
Python: Advanced Predictive Analytics

Python: Advanced Predictive Analytics

Ashish Kumar, Joseph Babcock

Publisher Resources

ISBN: 9781785886188Supplemental Content