Analyzing Google’s Winter Olympics Search Traffic with R

March 2, 2010

(This article was first published on Revolutions, and kindly contributed to R-bloggers)

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

To leave a comment for the author, please follow the link and comment on their blog: Revolutions. offers daily e-mail updates about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...

If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Tags: , ,

Comments are closed.


Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)