sd_skip_forward function

Define forward skip conditions for survey pages

Define forward skip conditions for survey pages

This function is used to define conditions under which certain pages in the survey should be skipped ahead to (forward only). It takes one or more formulas where the left-hand side is the condition and the right-hand side is the target page ID.

sd_skip_forward(...)

Arguments

  • ...: One or more formulas defining skip conditions. The left-hand side of each formula should be a condition based on input values, and the right-hand side should be the ID of the page to skip to if the condition is met. Only forward skipping (to pages later in the sequence) is allowed.

Returns

A list of parsed conditions, where each element contains the condition and the target page ID.

Examples

if (interactive()) { library(surveydown) # Get path to example survey file survey_path <- system.file("examples", "sd_skip_forward.qmd", package = "surveydown") # Copy to a temporary directory temp_dir <- tempdir() file.copy(survey_path, file.path(temp_dir, "survey.qmd")) orig_dir <- getwd() setwd(temp_dir) # Define a minimal server server <- function(input, output, session) { # Skip forward to specific pages based on fruit selection sd_skip_forward( input$fav_fruit == "apple" ~ "apple_page", input$fav_fruit == "orange" ~ "orange_page", input$fav_fruit == "other" ~ "other_page" ) sd_server() } # Run the app shiny::shinyApp(ui = sd_ui(), server = server) # Clean up setwd(orig_dir) }

See Also

sd_show_if()

  • Maintainer: John Paul Helveston
  • License: MIT + file LICENSE
  • Last published: 2025-03-18