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 to do it...

To create plots with the lattice package, follow these steps:

  1. Install and Load the lattice package:
> library(lattice) 
  1. Draw a boxplot:
> bwplot(~auto$mpg|cyl.factor, main="MPG by Number of     Cylinders",xlab="Miles per Gallon") 
  1. Draw a scatterplot:
> xyplot(mpg~weight|cyl.factor, data=auto,     main="Weight Vs MPG by Number of Cylinders",     ylab="Miles per Gallon", xlab="Car Weight") 

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