gsheet is a simple package to download [Google Sheets](https://www.google.com/sheets/about/ (aka Google Docs Spreadsheets) using just the sharing link. Sheets can be downloaded as a data frame, or as plain text to parse manually.
Install from CRAN with:
install.packages('gsheet')
Or install the latest development version from github with:
::install_github("maxconway/gsheet") devtools
Download a google sheet as a table with:
library(gsheet)
gsheet2tbl('docs.google.com/spreadsheets/d/1I9mJsS5QnXF2TNNntTy-HrcdHmIF9wJ8ONYvEJTXSNo')
If you want more control, you might want to use something like:
<- 'docs.google.com/spreadsheets/d/1I9mJsS5QnXF2TNNntTy-HrcdHmIF9wJ8ONYvEJTXSNo'
url <- gsheet2text(url, format='csv')
a <- read.csv(a, stringsAsFactors=FALSE) b
This way the table can be cleaned before parsing, and different options can be used in parsing.
If you want to download a sheet other than the first, you have to use the direct url, copied from the address bar, like so:
<- 'docs.google.com/spreadsheets/1I9mJsS5QnXF2TNNntTy-HrcdHmIF9wJ8ONYvEJTXSNo#gid=850032961'
url <- gsheet2tbl(url) b
This works because this makes the gid
, which is the
sheet identifier, available. If you have problems downloading the first
sheet, this can also help too.