O'Reilly logo

R Data Analysis Cookbook - Second Edition by Kuntal Ganguly

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

How it works...

Lattice plot commands comprise the following four parts:

  • Graph type: This can be bwplot, xyplot, densityplot, splom, and so on
  • Formula: Variables and factor variables separated by |
  • Data: A data frame containing values
  • Annotations: These include caption, axis label, and y axis label

In the boxplot, step 2, the ~auto$mpg|cyl.factor formula instructs lattice to make the plot with mpg on the x axis, grouped by factors representing cylinders. Here, we have not specified any variable for the y axis. For boxplots and density plots, we need not specify the y axis. The output for boxplot resembles the following diagram:

 

In the ...

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