Analyzing Google’s Winter Olympics Search Traffic with R
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
The Official Google Blog today includes an analysis of Google’s search traffic related to the recently-concluded Winter Olympics, correlating various high-profile events with searches from particular countries. For example, traffic from the United States shows the expected diurnal cycle but with promintent peaks for the opening ceremony and the hockey matches featuring the USA team:
It’s not specifically stated in the post, but it’s a good bet that R was used to create this analysis. It’s well known that R is in widespread use at Google, but the telltale sign here is the Y axis label. Google’s traditionally coy about giving exact figures for search numbers, and in this chart the search volumes have been suppressed. That’s easy to do in R, by passing the yaxt=”n” option (“Y axis type: none”) to the plot command. Here’s an example, using the built-in lynx data set:
> plot(lynx,yaxt=”n”)
That tends to leave the Y axis label a bit too far off the axis itself though (it leaves room for number labels that are no longer there), but you can move it into place with an explicit call to the mtext function to place the label 1 line of text from the axis (and suppressing the original axis label with ylab=”” when calling plot):
> plot(lynx,yaxt=”n”,ylab=””)
> mtext(“Lynx pelts”,side=2,line=1)
I’d bet good money that similar code was used for these plots. Now if only that could recoup my losses from the USA-Canada hockey final…
Official Google Blog: Searching for gold during the Games
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.