Quetzio_label_update | R Documentation |
Update Quetzio labels triggered by reactive value change
Quetzio_label_update( Quetzio, trigger, source_method, source_yaml = NULL, source_gsheet_id = NULL, source_gsheet_sheetname = NULL, source_object = NULL, name = NULL ) ## S3 method for class 'Quetzio' Quetzio_label_update( Quetzio, trigger, source_method, source_yaml = NULL, source_gsheet_id = NULL, source_gsheet_sheetname = NULL, source_object = NULL ) ## S3 method for class 'QuetzioLink' Quetzio_label_update( Quetzio, trigger, source_method, source_yaml = NULL, source_gsheet_id = NULL, source_gsheet_sheetname = NULL, source_object = NULL, name = NULL )
Quetzio |
object of class |
trigger |
reactive which will trigger the update. It needs to take values linked to the changes in the source |
source_method |
character string specifying in what form the source config file will be provided. Can be either 'gsheet', 'yaml' or 'raw'. Necessity of other arguments is dependent on this choice. |
source_yaml |
path to the source yaml file |
source_gsheet_id |
id of the source googlesheet file |
source_gsheet_sheetname |
name of the source spreadsheet |
source_object |
object of class |
name |
string indicating in which questionnaire the questions to update
are located. Used with |
## only run examples in interactive environment if (interactive()) { library(shiny) library(shiny.quetzio) ui <- fluidPage( # some input to trigger label update selectizeInput("gender", "What is your gender?", choices = c("Male" = "M", "Female" = "F", "I identify as neither of above" = "O", "Prefer not to say" = "NI"), selected = "NI"), tags$hr(), # quetzio to update labels Quetzio_UI("updating_labels") ) server <- function(input, output, session) { quetzio <- Quetzio_create( source_method = "raw", source_object = quetzio_examples$questions_lists$gender_update, module_id = "updating_labels" ) # trigger need to be reactive gender_react <- reactive(input$gender) # update labels method call Quetzio_label_update( Quetzio = quetzio, trigger = gender_react, source_method = "raw", source_object = quetzio_examples$label_update$gender_update ) } shinyApp(ui, server) } ## only run examples in interactive environment if (interactive()) { library(shiny) library(shiny.quetzio) ui <- fluidPage( # some input to trigger label update selectizeInput("gender", "What is your gender?", choices = c("Male" = "M", "Female" = "F", "I identify as neither of above" = "O", "Prefer not to say" = "NI"), selected = "NI"), tags$hr(), # quetzio to update labels QuetzioLink_UI("labels_link") ) server <- function(input, output, session) { quetzio_link <- QuetzioLink_create( quetzio_2nd = Quetzio_create( source_method = "raw", source_object = quetzio_examples$questions_lists$simple_quetzio, module_id = "second_in_link" ), gender = Quetzio_create( source_method = "raw", source_object = quetzio_examples$questions_lists$gender_update, module_id = "updating_labels" ), link_id = "labels_link") # trigger need to be reactive gender_react <- reactive(input$gender) # update labels method call Quetzio_label_update( Quetzio = quetzio_link, # you need to provide the name of the quetzio_server in link # where you need to update labels name = "gender", # the trigger needs to be reactive, but without the parentheses trigger = gender_react, source_method = "raw", source_object = quetzio_examples$label_update$gender_update ) } shinyApp(ui, server) }
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.