Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a good R API for accessing Google Docs?

I'm using R for data analysis, and I'm sharing some data with collaborators via Google docs. Is there a simple interface that I can use to access a R data.frame object to and from a Google Docs spreadsheet? If not, is there a similar API in other languages?

like image 562
James Thompson Avatar asked Apr 19 '10 06:04

James Thompson


People also ask

Is there an API for Google Docs?

The Google Docs API lets you create and modify documents. Apps can integrate with the Docs API to create polished documents from both user and system-provided data. The API allows you to: Automate processes.

How do I access google sheets in R?

You can read google sheets data in R using the package 'googlesheets4' . This package will allow you to get into sheets using R. First you need to install the 'googlesheets4' package in R and then you have to load the library to proceed further.


Video Answer


3 Answers

There are two packages:

  • RGoogleDocs on Omegahat: the package allows you to get a list of the documents and details about each of them, download the contents of a document, remove a document, and upload a document, even binary files.
  • RGoogleData on RForge: provides R access to Google services through the Google supported Java API. Currently the R interface only supports Google Docs and Spreadsheets.
like image 130
rcs Avatar answered Sep 25 '22 18:09

rcs


As of 2015, there is now the googlesheets package. It is the best option out there for analyzing and editing Google Sheets data in R. Not only can it pull data from Google Sheets, but you can edit the data in Google Sheets, create new sheets, etc.

The GitHub link above has a readme with usage details; there's also a vignette for getting started, or you can find the official documentation on CRAN.

like image 35
Sam Firke Avatar answered Sep 25 '22 18:09

Sam Firke


This may partially answer the question, or help others who want to begin by only downloading FROM public google spreadsheets: http://blog.revolutionanalytics.com/2009/09/how-to-use-a-google-spreadsheet-as-data-in-r.html#

I had a problem with certificates, and instead of figuring that out, I use the option ssl.verifypeer=FALSE. E.g.:

getURL("https://<googledocs URL for sharing CSV>, ssl.verifypeer=FALSE)
like image 30
Steve Koch Avatar answered Sep 23 '22 18:09

Steve Koch