David Smith has a great post over at Revolutions on charting time series as calendar heat maps in R. He includes source code from Paul Bleicher to create the heatmaps in R.
I track the sales data for my company’s iPhone apps using AppViz and thought it’d be interesting to whip up a graph of my iPhone app revenue in this format. Here’s the result (red is low revenue, green is high):
Sales peaked in January when the Mappity offline city maps apps were released, and have been falling since then. Those blank spots in the second half of 2009 are days of $0 in revenue.
Interestingly, it looks like Mondays and Tuesdays are relatively weak days for sales. This is probably due to customers going back to work or school.
If you’re an app developer and would like to generate a graph like this of your own, it’s really easy. If you have AppViz, export your data in the “Revenue by Day” format. Then, run the Python script I wrote to convert the data, which is available on GitHub.
Download the calendarHeat.R file from the original blog post and import it into R. Then, import the reformatted revenue data and generate the graph with this bit of R code:
data <- read.csv("PATH TO DATA", as.is=TRUE, sep='\t')
data <- transform(data,
week = as.POSIXlt(Date)$yday %/% 7 + 1,
wday = as.POSIXlt(Date)$wday,
year = as.POSIXlt(Date)$year + 1900)
calendarHeat(data$Date, data$Converted.Revenue, varname="iPhone Revenue")
Replace "PATH TO DATA" with the path to your CSV file to import the data. Enjoy!
One Response
Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.
Continuing the Discussion