README.md

googleforms

I created this package because I wanted several features not implemented in Google Forms. This is a spin off of the shinyforms package. I wanted survey participants to be able to come back to the survey and edit/change/update their responses and I wanted to be able to have the app email the unique ID that is created for them to allow them to return and edit their responses. This package uses the {googledrive}, {googlesheets4}, and {gmailr} packages to persistently store data as google sheets and email participants. Usually storing credentials and authentication tokens can be tricky in shiny apps so this was designed to hopefully just work. You will have to create the app and use it interactively once and do the so-called “OAuth Dance” but then the googleforms package will store the tokens in the ‘.secrets’ folder in the shiny app directory. Make sure to upload that folder when publishing to shinyapps.io. Additionally, to use {gmailr} you will need to set up a ‘credentials.json’ and manually move it into the shiny app home directory as the app will look for the credentials by using here::here(‘credentials.json’). More information on setting up gmailr here.

Installation

You can install the released version of googleforms from GitHub using devtools:

devtools::install_github("brentscott93/googleforms")

Example

This is a basic example which will show basic use saving files locally to disk:

# library(shiny)
# library(shinydashboard)
# library(googleforms)
# googleform(
#   title = 'My Survey',
#   description = 'About my suervey here.',
#   questions = list(
#                  list(id = "age", type = "numeric", title = "Age (yrs)", required = T),
#                  list(id = "height", type = "height", title = "Height (ft-in)", required = T),
#                  list(id = "weight_lbs", type = "numeric", title = "Weight (lbs)", required = F)
#                 ),
#   folder = 'googleforms-results',
#   returningUser = T
# )

Example with google storage and gmail:

# library(shiny)
# library(shinydashboard)
# library(googleforms)
# googleform(
#   title = 'My Survey',
#   description = 'About my survey here.',
#   questions = list(
#                  list(id = "age", type = "numeric", title = "Age (yrs)", required = T),
#                  list(id = "height", type = "height", title = "Height (ft-in)", required = T),
#                  list(id = "weight_lbs", type = "numeric", title = "Weight (lbs)", required = F)
#                 ),
#   folder = 'googleforms-results',
#   returningUser = T,
#   #just replace with your email
#   gmail = 'brentscott93@gmail.com',
#   #if you dont have gmailr setup do emaiId = F
#   emailId = T,
#   subject = 'My Survey ID'
# )

Test screen record:



brentscott93/googleforms documentation built on Sept. 2, 2020, 12:37 p.m.