if (interactive()) {
library(surveydown)
# Get path to example survey file
survey_path <- system.file("examples", "sd_skip_if.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 to page based on input
sd_skip_if(
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)
}
Run the code above in your browser using DataLab