1

I would like to download a google docs spreadsheet using R and then import the spreadsheet as a csv file in a small shiny server app. How could I do that?

TMOTTM
  • 3,286
  • 6
  • 32
  • 63
  • possible duplicate of [read.csv fails to read a CSV file from google docs](http://stackoverflow.com/questions/5834821/read-csv-fails-to-read-a-csv-file-from-google-docs) – r.bot Apr 04 '15 at 19:39
  • http://cran.r-project.org/web/packages/gsheet/gsheet.pdf might be helpful – Tyler Rinker Apr 04 '15 at 19:44

2 Answers2

6

Try the new googlesheets package, which is an R API for Google Sheets:

https://github.com/jennybc/googlesheets

This snippet will install the package, copy a Sheet to your Google Drive, register it for access, and import data from one tab or worksheet into a local data.frame:

devtools::install_github("jennybc/googlesheets")
gap_key <- "1HT5B8SgkKqHdqHJmn5xiuaC04Ngb7dG9Tv94004vezA"
copy_ss(key = gap_key, to = "Gapminder")
gap <- register_ss("Gapminder")
oceania_csv <- get_via_csv(gap, ws = "Oceania")

As for integration with Shiny, see the shinyga package which recently incorporated support for googlesheets:

https://github.com/MarkEdmondson1234/shinyga

jennybryan
  • 2,606
  • 2
  • 18
  • 33
0

You can use RGoogle Docs package to access the Google Docs content. Other option worth consider is the RGoogle Data package that provides access to Google services.

Konrad
  • 17,740
  • 16
  • 106
  • 167