DataCamp
Data Visualization in R with lattice
DATA VISUALIZATION IN R WITH LATTICE
New methods Deepayan Sarkar Associate Professor, Indian Statistical Institute
DataCamp
Non-formula methods High-level lattice functions are "generic functions" First argument need not be a formula Example: Dot plots for tables (matrices, arrays)
Data Visualization in R with lattice
DataCamp
Dot plot on tables: WorldPhones revisited > dotplot(WorldPhones[-1, ], scales = list(x = list(log = 2)), + groups = FALSE, layout = c(1, NA), + strip = FALSE, strip.left = TRUE)
Data Visualization in R with lattice
DataCamp
Dot plot on tables: WorldPhones revisited > dotplot(WorldPhones[-1, ], scales = list(x = list(log = 2)), + groups = TRUE, par.settings = simpleTheme(pch = 16), + auto.key = list(columns = 7))
Data Visualization in R with lattice
DataCamp
Dot plot on named vector > dotplot(sort(precip), xlab = "Average annual precipitation (in.)")
Data Visualization in R with lattice
DataCamp
Data Visualization in R with lattice
DATA VISUALIZATION IN R WITH LATTICE
Let's practice!
DataCamp
Data Visualization in R with lattice
DATA VISUALIZATION IN R WITH LATTICE
New high-level functions Deepayan Sarkar Associate Professor, Indian Statistical Institute
DataCamp
New high-level functions Completely new high-level functions can also be created Needed when panel function is not enough Example: horizonplot() in the latticeExtra package
Data Visualization in R with lattice
DataCamp
Horizon plots > library(latticeExtra) > horizonplot(EuStockMarkets, colorkey = TRUE)
Data Visualization in R with lattice
DataCamp
Data Visualization in R with lattice
Another example: choropleth maps Location-tagged data often best displayed using maps Regions colored according to measurements being displayed Known as choropleth maps Example: mapplot() in the latticeExtra package
DataCamp
Data Visualization in R with lattice
Choropleth map of USCancerRates data > library(maps) > library(mapproj) > county.map library(latticeExtra) > mapplot(rownames(USCancerRates) ~ log(rate.male), + data = USCancerRates, xlab = "", scales = list(draw = FALSE), + main = "Log-transformed death rates in males (per 100,000)", + map = county.map)
DataCamp
Choropleth map of USCancerRates data
Data Visualization in R with lattice
DataCamp
Data Visualization in R with lattice
DATA VISUALIZATION IN R WITH LATTICE
Let's practice!
DataCamp
Data Visualization in R with lattice
DATA VISUALIZATION IN R WITH LATTICE
Manipulation of trellis objects Deepayan Sarkar Associate Professor, Indian Statistical Institute
DataCamp
Operating on the "trellis" object > p p
Data Visualization in R with lattice
DataCamp
The useOuterStrips() function > library(latticeExtra) > useOuterStrips(p)
Data Visualization in R with lattice
DataCamp
Data Visualization in R with lattice
DATA VISUALIZATION IN R WITH LATTICE
Let's practice!