I want to use Google google spreadsheet or form + spreadsheet to collect a response from an R user and sent it to a speadsheet.
Here is a minimal Google form: https://docs.google.com/forms/d/1tz2RPftOLRCQrGSvgJTRELrd9sdIrSZ_kxfoFdHiqD4/viewform
And the accompanying spreadsheet: https://docs.google.com/spreadsheets/d/1xemHzTdeqgMuGbsP6oqDYuMu4PymBdw7k7kMC_-Dsi8/edit#gid=102827002
I thought I'd use Jenny Bryan's googlesheets package like so:
library(googlesheets);library(dplyr)
(my_sheets <- gs_ls())
minresp <- gs_title("minimal (Responses)")
minresp %>% gs_add_row(ws = "dat", input = mtcars[20, 1:2])
Works great but if I include the code and someone else (i.e., who is not me) tries to use the code:
Error in gs_lookup(., "sheet_title", verbose) :
"minimal (Responsess)" doesn't match sheet_title of any sheet returned by gs_ls() (which should reflect user's Google Sheets home screen).
So in the vignette I see there's apart:
# Need to access a sheet you do not own?
# Access it by key if you know it!
I figured this was the ticket to allow others to input data into a spreadsheet so I tried:
minresp2 <- gs_key("1xemHzTdeqgMuGbsP6oqDYuMu4PymBdw7k7kMC_-Dsi8")
yielding:
Authentication will be used.
Error in gs_lookup(., "sheet_key", verbose) :
"1xemHzTdeqgMuGbsP6oqDYuMu4PymBdw7k7kMC_-Dsi8" doesn't match sheet_key of any sheet returned by gs_ls() (which should reflect user's Google Sheets home screen).
This all works if I'm logged into and authenticated via google, but how could I make it so users could add to my spreadsheet. I don't care what approach/packages one uses. It's be nice if the user could only edit the spreasheet via the use in the function and not simply look at the source and get the url and edit manually but that's less of a concern.
Essentially I want to be able to collect responses from an R user in a spreadsheeet (or other data form) and append with each new user.