Using R and Google Sheets
Today, I meet a big problem about my ERP system built in Google Sheets, and I don’t want to shape a too complicated one such as WordPress or Django.
In that, inspired by gspread , a python package, I am trying googlesheets package , a counterpart of another R package.
Firstly, download the git repository and install.
library ( devtools )
devtools :: install_github ( "hadley/readr" )
## Downloading GitHub repo hadley/readr@master
## Error in curl::curl_fetch_memory(url, handle = handle): Timeout was reached
devtools :: install_github ( "jennybc/googlesheets" )
## Downloading GitHub repo jennybc/googlesheets@master
## Installing googlesheets
## Skipping 5 packages ahead of CRAN: dplyr, jsonlite, mime, Rcpp, tidyr
## '/Library/Frameworks/R.framework/Resources/bin/R' --no-site-file \
## --no-environ --no-save --no-restore CMD INSTALL \
## '/private/var/folders/f2/9jwh0h8s4y70r1jl3s7cq_5c0000gn/T/RtmpN3HfZO/devtoolsc3c37718540a/jennybc-googlesheets-067e4a3' \
## --library='/Library/Frameworks/R.framework/Versions/3.2/Resources/library' \
## --install-tests
If you’re network blocked, you could download manually.
$git clone $git@github.com:jennybc/googlesheets.git
$R CMD INSTALL googlesheets
Now, we could manipulate googlesheets with R.
library ( googlesheets )
gs_ls () # authenticated in a popup website
## Error: oauth_listener() needs an interactive environment.
ss <- gs_title ( "My_December_Table" ) # read a SpreadSheet from your accout
## Error: oauth_listener() needs an interactive environment.
gs_read ( bb , ws = 3 , range = "A1:D20" ) # read a sheet , ws means WorkSheet number
## Error in inherits(ss, "googlesheet"): object 'bb' not found
bb <- gs_edit_cells ( ss , input = head ( iris ), trim = TRUE ) # edit the table
## Error in inherits(ss, "googlesheet"): object 'ss' not found
gs_read ( ss )
## Error in inherits(ss, "googlesheet"): object 'ss' not found
the more method you can see the official manual and shiny exampl !
Reference:Jennifer in UsingR Conference 2015
Related Shiny Examples