Slope graphs and exporting multi-paneled plots (with data) in R

I’ve been trying to carve out the time to write a post about the GooleVis package and, more specifically, how AWESOME motion charts are within GoogleVis, but in the mean-time, I’ve been spending a lot of time thinking about data visualizations. I think that the act of putting together an entry for Naomi Robbin’s Forbes Graph Challenge had this kind of an impact on my consciousness. Anyhow, a few early responders to Naomi’s post were discussing slope graphs (http://www.edwardtufte.com/bboard/q-and-a-fetch-msg?msg_id=0003nk) and it inspired me to seek out ways to incorporate these into some of my data presentations. I found a most excellent post here about producing them in R (http://www.jameskeirstead.ca/r/slopegraphs-in-r/).  I will look for ways to incorporate these where they make sense in any future reporting.

Also, my issue of the week involved putting together a report that did an analysis of 300+ therapeutic groupings, where for each grouping I had to work out a way to get both an informative plot AND multiple pieces of data (2 data frames) to export to a single image. I resolved my issue with some help from gplots textplot() function.

testMat <- matrix(1:20, ncol = 5)##  create data
testMatDF <- as.data.frame(testMat)
names(testMatDF) <- c("Hey there", "Column 2",
         "Some * Symbols", "And ^ More",
         "Final Column")
rownames(testMatDF) <- paste("Group", 1:4)

library(gplots) ##  gplots needed for textplot()
layout(matrix(c(1, 1, 2, 3, 3, 3),  2, 3, byrow = TRUE))
curve(dnorm, -3, 4)
textplot(testMat)
textplot(testMatDF)
##  produces what I want within R

png(file='plot1.png')
layout(matrix(c(1, 1, 2, 3, 3, 3),  2, 3, byrow = TRUE))
curve(dnorm, -3, 4)
textplot(testMat)
textplot(testMatDF)
dev.off() ##  how to export the same
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s