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 (https://code.google.com/apis/storage/docs/gsutil_install.html)
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 'https://www.revolution-computing.com/cran/bin/macosx/leopard/contrib/2.13/rjson_0.2.5.tgz' Content type 'application/x-gzip' length 133138 bytes (130 Kb) opened URL ================================================== downloaded 130 Kb The downloaded packages are in /var/folders/I3/I3YZ8e5tGOK9CY9LQ98ix++++TI/-Tmp-//RtmpFrtdp3/downloaded_packages
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
https://code.google.com/p/google-prediction-api-r-client/
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
library(rjson) library(RCurl) library(googlepredictionapi)
Some useful links https://mjaniec.blogspot.com/2011/05/google-prediction-api-v12-for-r.html https://code.google.com/p/google-prediction-api-r-client/ https://code.google.com/p/r-google-prediction-api-v12/
https://csg.sph.umich.edu/docs/R/localpackages.html
- 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: https://code.google.com/apis/storage/docs/gsutil_install.html
- Download the Google Predictions API for R from https://code.google.com/p/google-prediction-api-r-client/
-
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.