Postscript to Data Visualization

July 23, 2013

(This article was first published on Fear and Loathing in Data Science, and kindly contributed to R-bloggers)

Much to my chagrin, I realized I forgot to include one of the more interesting features in the lattice package. You can quickly turn a quantitative variable into one of levels of equal counts.  This provides a nice way of looking at slices of your data in a trellis plot.  These slices are referred to as shingles as they overlap according to your specification.

Here is a simple code example, using the quakes data included with R:

> library(lattice)
> head(quakes)
     lat          long    depth mag stations
1 -20.42 181.62   562    4.8       41
2 -20.62 181.03   650    4.2       15
3 -26.00 184.10    42     5.4       43
4 -17.97 181.66   626    4.1       19
5 -20.42 181.96   649    4.0       11
6 -19.68 184.31   195    4.0       12
#Build an xyplot of lat and long conditioned by depth
> depth = quakes$depth
> range(depth)

[1]  40 680

> Depth = equal.count(depth, number=6, overlap=.05)
> # with equal.count we now have sliced depth into 6 parts with an overlap of 5%

xyplot(lat~long | Depth, data=quakes)

The way to read this plot is starting from the bottom left working right then the next row up from left to right.



To leave a comment for the author, please follow the link and comment on their blog: Fear and Loathing in Data Science. offers daily e-mail updates about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...

If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Comments are closed.

Search R-bloggers


Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)