Site icon R-bloggers

Postscript to Data Visualization

[This article was first published on Fear and Loathing in Data Science, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
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%
plot(Depth)





















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.


































Enjoy.

TDM

To leave a comment for the author, please follow the link and comment on their blog: Fear and Loathing in Data Science.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.