-
Notifications
You must be signed in to change notification settings - Fork 22
Can't store values to data in reactive environment #179
Description
Discussed in https://github.com/orgs/surveydown-dev/discussions/178
Originally posted by StefanMunnes February 3, 2025
Description
Hello,
I can't help myself again. For a kind of Wiki-Survey, which I could already implement successfully with surveydown, I fail to save values in a new variable. For the pairwise comparison of statements, an Excel file is loaded in the app.R file at the beginning and the different paired statements are stored randomly in a nested list object. Depending on the selection in a prior question, a set of different pairs is selected from this nested list, which are then displayed and evaluated one after the other. The display and answering works well, also the storing of the chosen statement. However, I can't get the pair of statements that was shown stored in the data with sd_store_value().
To give you an idea what this wiki-survey looks like (but in german), check: https://shiny2.wzb.eu/munnes/wikisurvey/
In the server() function in the app.Rfile I have an observer function, looping through the chosen set of pairs and creating a question for each set. To know which two randomly assigned statements the participants could choose from in this questions, I try to store this two values as a collapsed text value:
shiny::observe({
if (!is.null(input$question)) {
for (pair in seq_along(pairs[[input$question]])) {
pair_items <- paste(pairs[[input$question]][[pair]], collapse = ",")
# this is the line that I expect to store each pair to the data, but it doesn't work
sd_store_value(pair_items, paste0("wiki_pair_", pair))
sd_question(
id = paste0("wiki_", pair),
type = "mc_buttons",
label = NULL,
direction = "vertical",
option = pairs[[input$question]][[pair]]
)
}
}
})
```</div>