I claim absolutely no credit for this visualization, which I consider one of the most best I have ever seen. All credit belongs to the original source. If anybody believes this to be not fair use, I will take it down immediately. I am implicitly assuming approval for this fork due to the data.stories interview.
I think we all know the data visualization team at NYT is simply amazing. Earlier this year in my post d3 <- R with rCharts and slidify I adapted and recreated the 512 Paths to the White House to work with
R data through
rCharts. Unfortunately, I was not creative enough to think of other data sets to plug into the visualization. When Scott Murray tweeted,
I immediately knew the Case Shiller Home Price Index visualization would be perfect for reuse with any cumulative growth time series data. This is a bit of a hack of
rCharts and should not be considered best practices, but it is a demonstration of the very flexible design of the package. In the spirit of this discussion, I did not want to just copy entirely. I was able to add a couple key innovations to the visualization:
rChartsto make it reusable.
As I mentioned above, this visualization works well with any cumulative growth time series, so let's apply it to the
managers dataset supplied by the
#get the data and convert to a format that we would expect from melted xts #will be typical #also original only uses a single value (val) and not other require(reshape2) require(PerformanceAnalytics) data(managers) managers <- na.omit(managers) managers.melt <- melt( data.frame( index( managers ), coredata(cumprod( managers+1 )*100 ) ), id.vars = 1 ) colnames(managers.melt) <- c("date", "manager","val") managers.melt[,"date"] <- format(managers.melt[,"date"],format = "%Y-%m-%d")
require(rCharts) p2 <- rCharts$new() p2$setLib('libraries/widgets/nyt_home') p2$setTemplate(script = "libraries/widgets/nyt_home/layouts/nyt_home.html") p2$set( description = "This data comes from the managers dataset included in the R package PerformanceAnalytics.", data = managers.melt, groups = "manager" ) cat(noquote(p2$html()))
|Year-over-year change||Since peak||Since Jan. 2000|
As I hope you can tell, this post was more a function of the efforts of others than of my own.