Installing the Google Predictions API in R

Note: This post got buried and I never posted it. I haven’t played with R in several months, so I’m not sure if this works anymore.

This assumes you have R downloaded and installed.

Download, install, and configure GSUtil (

Load R. You should see an ugly console :) In the window type

install.packages(c("RCurl", "rjson"))

You will be prompted to select a mirror; find something close to you and continue.

You might be frustrated that there’s no success message:

trying URL ''
Content type 'application/x-gzip' length 133138 bytes (130 Kb)
opened URL
downloaded 130 Kb

The downloaded packages are in

However, if you fail there will be an error message:

> install.packages("seth", dependencies = TRUE)
Warning message:
In getDependencies(pkgs, dependencies, available, lib) :
  package ‘seth’ is not available (for R version 2.13.0)
> install.packages("googlepredictionapi_0.1.tar.gz", repos=NULL, type="source")
Warning: invalid package ‘googlepredictionapi_0.1.tar.gz’
Error: ERROR: no packages specified
Warning message:
In install.packages("googlepredictionapi_0.1.tar.gz", repos = NULL,  :
  installation of package 'googlepredictionapi_0.1.tar.gz' had non-zero exit status

Download the Google Predictions API for R

Install it

$ mkdir -p ~/R/library
$ mv googlepredictionapi_0.1.tar.gz ~/R/library/
$ R_LIBS_USER="~/R/library"
$ echo 'R_LIBS_USER="~/R/library"' >  $HOME/.Renviron
R CMD INSTALL ~/R/library/googlepredictionapi_0.1.tar.gz

Source your libraries


Some useful links

  • Load R Note: You will see an ugly console.
  • Install the pre-reqs

    install.packages(c(“RCurl”, “rjson”))

  • Note: If you have not installed a package from CRAN before, You will  be prompted to select a mirror; find something close to you and continue.

  • Note: A successful install will not yield a success message—it will simply not show an error message.

  • Download, install, and configure GSUtil:

  • Download the Google Predictions API for R from
  • Install the plugin Note: I had to do it from the command line because the install failed inside R

    $ R CMD INSTALL your/path/to/googlepredictionapi_0.1.tar.gz

  • Now, you should be able to restart R and see the API listed in the Package Manager

  • From here we source our libraries

    library(rjson) library(RCurl) library(googlepredictionapi)

  • If the data is already in your Google Storage account, you can begin training the model. I do not have data in GS yet, so I’ve stopped here.