In the exercises below, we will see features of the famous lattice graphics package.
Please see the documentation before trying the exercises.
Answers to the exercises are available here.
If you obtained a different (correct) answer than those listed on the solutions page, please feel free to post your answer as a comment on that page.
Lattice’s structure is similar to base r’s formula interface. Load the library and air quality data and create the histogram of Solar.R. The right hand side of the formula represents the x-axis in a 2D viz. Give the plot a descriptive name and label the x-axis as “Solar Level.”
Create the same plot using the number of bins as 20.
Hint: nint param
In the same plot, use the type count AND type percent to see how the plot looks when using different types.
Create a density plot with the air quality data for the Solar.R variable. Density plot is another alternative to histograms.
Create a scatter plot of the Ozone vs. Solar.R via lattice.
In the same plot, add a reference line representing the distribution using “abline.”
Suppose you want to see the different distribution of a continuous variable with respect to a categorical variable; for example, in the Iris data, to see the distribution of Sepal.Width with respect to different species. Create a box and whisker plot.
Make the bw plot to see the whisker extend to the extreme outliers.
It’s easy to see how 3 species varies when comparing Sepal.Length with respect to Sepal.Width. How can you plot them in one plot?
Similarly see the similar Solar.R for every month as a density plot in a single plot.
This is fun, thanks