Description Usage Arguments Value Examples
View source: R/fct_googleform.R
Create a shiny app with minimal code that mimicks that looks of a Google Form. Currently only stores data in Google Drive (or locally) and has the option to allow survey participants to return and edit their survey with a unique ID. Optionally, this ID can be emailed to the user. Requires one-time setup of googledrive, googlesheets4, and gmailr
1 2 3 4 5 6 7 8 9 10 11 12 | googleform(
title = NULL,
description = NULL,
questions = NULL,
gmail = F,
folder,
color = "#2e77ff",
returningUser = F,
emailId = F,
subject = "Your survey ID",
public = F
)
|
title |
a character string. |
description |
a character string. |
questions |
a nested list of questions. |
gmail |
FALSE or your gmail account to store data in drive and optionally to email IDs to users. |
folder |
a character string specicifying the folder on desktop/drive to store results in. |
color |
a character string of a hex color to theme the app. Default is blue. |
returningUser |
logical. Do you want users to return to edit/update their survey. Default is FALSE |
emailId |
logical. Do you want to email ID to users. Default is FALSE |
subject |
a character string. For the subject of your emaill. Default is 'Your survey ID' |
public |
logical. Do you want the results to be saved in a public google drive folder? |
a shiny app
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | if(interactive()){
library(shiny)
library(shinydashboard)
library(shinyforms)
googleform(
title = "My Survey",
description = 'Describe your 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 = T),
list(id = 'ethnicity',
type = "multiplechoice",
title = "Are you of Hispanic, Latino, or of Spanish origin?" ,
choices = list('No', 'Yes'),
required = T),
list(id = "race",
type = "multiplechoice",
title = "Race",
choices = list('American Indian or Alaska Native',
'Asian',
'Black or African American',
'Native Hawaiian or Other Pacific Islander',
'White',
'Other'),
required = T),
list(id = "bp_systolic",
type = "numeric",
title = "Blood Pressure (Systolic)"),
list(id = "bp_diastolic",
type = "numeric",
title = "Blood Pressure (Diastolic)"),
list(id = "resting_HR",
type = "numeric",
title = "Resting Heart Rate")
),
gmail = F,
folder = 'shinyforms'
)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.