Create the UI code for a Shiny app based on user-supplied questions.

surveyOutput(df, survey_title, survey_description, theme = "#63B8FF", ...)

Arguments

df

A user supplied data frame in the format of teaching_r_questions.

survey_title

(Optional) user supplied title for the survey

survey_description

(Optional) user supplied description for the survey

theme

A valid R color: predefined such as "red" or "blue"; hex colors such as #63B8FF (default). To customize the survey's appearance entirely, supply NULL.

...

Additional arguments to pass into actionButton used to submit survey responses.

Value

UI Code for a Shiny App.

Examples


if (interactive()) {

  library(shiny)
  library(shinysurveys)

  df <- data.frame(question = "What is your favorite food?",
                   option = "Your Answer",
                   input_type = "text",
                   input_id = "favorite_food",
                   dependence = NA,
                   dependence_value = NA,
                   required = F)

  ui <- fluidPage(
    surveyOutput(df = df,
                 survey_title = "Hello, World!",
                 theme = "#63B8FF")
  )

  server <- function(input, output, session) {
    renderSurvey()

    observeEvent(input$submit, {
      showModal(modalDialog(
        title = "Congrats, you completed your first shinysurvey!",
        "You can customize what actions happen when a user finishes a survey using input$submit."
      ))
    })
  }

  shinyApp(ui, server)

}