How to do it...

Perform the following steps:

  1. We begin exploring by visualizing the data with a boxplot:
        > boxplot(mtcars$mpg~factor(mtcars$gear),xlab='gear',ylab='mpg')
Comparison of mpg of different numbers of forward gears
  1. To visualize how gear and mpg is related, a dot plot is created using the following steps:
        > library(ggplot2)         > ggplot(mtcars,aes(mtcars$mpg,mtcars$gear, color         =mtcars$gear))+geom_point()
Graph for mpg vs gears
  1. Next, we conduct a one-way ANOVA to examine whether the mean of mpg changes with different numbers of ...

Get Machine Learning with R Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.