This function creates a copy of an input value and makes it available as a
new output. The new output can then be displayed using sd_output()
.
See also
sd_output()
for displaying the copied value
Examples
if (interactive()) {
library(surveydown)
# Get path to example survey file
survey_path <- system.file("examples", "sd_ui.qmd",
package = "surveydown")
# Copy to a temporary directory
temp_dir <- tempdir()
file.copy(survey_path, file.path(temp_dir, "sd_copy_value.qmd"))
orig_dir <- getwd()
setwd(temp_dir)
# Define a minimal server
server <- function(input, output, session) {
# Make a copy of the "name" variable to call its value a second time
sd_copy_value(id = "name", id_copy = "name_copy")
sd_server()
}
# Run the app
shiny::shinyApp(ui = sd_ui(), server = server)
# Clean up
setwd(orig_dir)
}