sd_reactive function

Create a reactive value that is also stored in survey data

Create a reactive value that is also stored in survey data

This function creates a reactive value similar to Shiny's reactive() function, but also automatically stores the calculated value in the survey data.

sd_reactive(id, expr, blank_na = TRUE)

Arguments

  • id: Character string. The id (name) of the value to be stored in the data.
  • expr: An expression that calculates a value based on inputs
  • blank_na: Logical. If TRUE, NA values are converted to empty strings. Default is TRUE.

Returns

A reactive expression that can be called like a function

Examples

## Not run: # In your server function: product <- sd_reactive("product", { input$first_number * input$second_number }) # Use the reactive value elsewhere output$result <- renderText({ paste("The product is:", product()) }) # In your survey.qmd file, display the value: The product is: `r sd_output("product", type = "value")`. ## End(Not run)
  • Maintainer: John Paul Helveston
  • License: MIT + file LICENSE
  • Last published: 2025-04-08