Skip to content

Month: May 2016

Milking Google Sheets with R

Google Sheets is a wonderful thing.  I use it to collate information from my students through Google Form (another wonderful invention). In short,  free Excel sheet on the cloud is readily available!

Since it is on the cloud, can I load it in R and use it directly there? Apparently we can.  I just had to ask the correct question.

There were multiple solutions in the stackoverflow site. I like the solution provided by Max Conway the best. Just three lines of code to accomplish it.

So. what’s the keeidea here?

First install the gsheet package. Then load the library. Finally, use the function gsheet2tbl to get the data in google sheet. The URL of the Google Sheet is kept within the brackets after the gsheet2tbl.

#install the gsheet package
install.packages('gsheet')

#load the gsheet library
library(gsheet)

#load data 
data<-gsheet2tbl('docs.google.com/spreadsheets/d/1I9mJsS5QnXF2TNNntTy-HrcdHmIF9wJ8ONYvEJTXSNo')

This way, you would have loaded the target Google Sheet as “data”.

Just three lines of codes to milk the Google Sheet using R! We have just supercharged the usability of Google Sheet!

Skip to toolbar