sd_output {surveydown} | R Documentation |
Output Function for Displaying reactive objects and values
Description
Output Function for Displaying reactive objects and values
Usage
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 corresponding
with the question |
width |
Character string. The width of the UI element. Defaults to
|
display |
Character string. Specifies the display type for |
inline |
Logical. Whether to render the output inline. Defaults to
|
wrapper |
Function. A function to wrap the output. Only used when
|
... |
Additional arguments passed to the underlying 'shiny' functions or the wrapper function. |
Details
The function behaves differently based on the type
parameter:
If
type
isNULL
, it acts likeshiny::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 thedisplay
parameter.
Value
A 'shiny' UI element, the type of which depends on the input parameters.
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)
}