Fork me on GitHub

Great NYT Interactive -- Now Reusable with rCharts

Disclaimer and Attribution

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.

Another Favorite from NYT

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,

Over at @nytgraphics, @KevinQ and @shancarter really know how to wiggle a baseline.

— Scott Murray (@alignedleft) June 25, 2013

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:

Reusable Version in rCharts

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 PerformanceAnalytics package.

Get Data and Transform

#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 

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")

Draw The Graph

p2 <- rCharts$new()
p2$setTemplate(script = "libraries/widgets/nyt_home/layouts/nyt_home.html")

  description = "This data comes from the managers dataset included in the R package PerformanceAnalytics.",
  data = managers.melt,
  groups = "manager"
If you bought around it would be worth 24 percent less today.

Behind the data

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.

Thanks specifically: