sd_output function

Output Function for Displaying reactive objects and values

Output Function for Displaying reactive objects and values

sd_output( id, type = NULL, width = "100%", display = "text", inline = TRUE, wrapper = NULL, ... )

Arguments

  • id: Character string. A unique identifier for the output element.

  • type: Character string. Specifies the type of output. Can be "question", "value", or NULL. If NULL, the function behaves like shiny::uiOutput().

  • width: Character string. The width of the UI element. Defaults to "100%".

  • display: Character string. Specifies the display type for "value"

    outputs. Can be "text", "verbatim", or "ui". Only used when type = "value".

  • inline: Logical. Whether to render the output inline. Defaults to TRUE.

  • wrapper: Function. A function to wrap the output. Only used when type = "value".

  • ...: Additional arguments passed to the underlying 'shiny' functions or the wrapper function.

Returns

A 'shiny' UI element, the type of which depends on the input parameters.

Details

The function behaves differently based on the type parameter:

  • If type is NULL, it acts like shiny::uiOutput().
  • If type is "question", it creates a placeholder for a reactive survey question.
  • If type is "value", it creates an output to display the value of a survey question, with the display style determined by the display parameter.

Examples

if (interactive()) { library(surveydown) # Get path to example survey file survey_path <- system.file("examples", "sd_output.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) { sd_server() } # Run the app shiny::shinyApp(ui = sd_ui(), server = server) # Clean up setwd(orig_dir) }
  • Maintainer: John Paul Helveston
  • License: MIT + file LICENSE
  • Last published: 2025-04-08