Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I allow new R users to send information to a Google Form?

Tags:

r

How can I allow new R users to send information to a Google Form? (RSelenium requires a bit of set up, at least for headless browsing, so it's not the best candidate IMO but I may be missing something that makes it the best choice).

I have some new R users I want to get responses from interactively and send to a secure location. I have chosen Google Forms to pass the information to, as it allows one way sends of the info and doesn't allow the user access to the spreadsheet that is created from the form.

Here's a url of this form:

url <- "https://docs.google.com/forms/d/1tz2RPftOLRCQrGSvgJTRELrd9sdIrSZ_kxfoFdHiqD4/viewform"

To give context here's how I'm using R to interact with the user:

question <- function(message, opts = c("Yes", "No")){
    message(message)
    ans <- menu(opts)
    if (ans == "2") FALSE else TRUE
}

question("Was this information helpful?")

I want to then send that TRUE/FALSE to the Google form above. How can I send a response to the Google Form above from within R in a way that I can embed in code the user will interact with and doesn't require difficult set up by the user?

Add on R packages are fine if they accomplish the task.

like image 494
Tyler Rinker Avatar asked Oct 27 '15 13:10

Tyler Rinker


People also ask

How do I make my Google form more accessible?

To make the form accessible to everyone, you have to manually set the setting. If your form requires a file upload, then the user needs to sign-in to their Google account to fill the form. No doubt, the form will be available among a larger audience but there is no such option of keeping track of respondent activity.

What can collaborators do on Google Forms?

When you share a Google form with a collaborator, you give that collaborator full editing access to the form. That collaborator will have the ability to make any changes they'd like to the form, including a change to where responses are collected.


1 Answers

You can send a POST query. Here an example using httr package:

For example:

library(httr)
send_response<- 
  function(response){
    form_url <- "https://docs.google.com/forms/d/1tz2RPftOLRCQrGSvgJTRELrd9sdIrSZ_kxfoFdHiqD4/formResponse"
    POST(form_url,
         query = list(`entry.1651773982`=response)
    )
  }

Then you can call it :

send_response(question("Was this information helpful?"))
like image 173
agstudy Avatar answered Oct 07 '22 09:10

agstudy