O'Reilly logo

Machine Learning with R Cookbook by Chiu Yu-Wei

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

Visualizing data

Visualization is a powerful way to communicate information through graphical means. Visual presentations make data easier to comprehend. This recipe presents some basic functions to plot charts, and demonstrates how visualizations are helpful in data exploration.

Getting ready

Ensure that you have completed the previous recipes by installing R on your operating system.

How to do it...

Perform the following steps to visualize a dataset:

  1. Load the iris data into the R session:
    > data(iris)
    
  2. Calculate the frequency of species within the iris using the table command:
    > table.iris = table(iris$Species)
    > table.iris
    
        setosa versicolor  virginica 
            50         50         50 
    
  3. As the frequency in the table shows, each species represents 1/3 of the iris data. We ...

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