I'm wanting to use checkboxInput to indicate which variables need to go into a scoring methodology (i.e., have the ability to leave some variables out if desired). I want the checkboxInput to be converted to a 0 or 1, and this number will be used in a scoring algorithm.
I know the scoring methodology is working because it will work when I have default variables chosen which ignore the checkboxInput, but not with these manual check boxes.
I'd greatly appreciate any help. Below isn't an exact replica of code; just a simplified version to make this easier for readers. If this way too simplified, let me know; the actual code is pretty complicated but I want to highlight the simple issue that's causing me such a headache for an unknown reason. Thank you!
I've tried making the checkboxInput a reactive variable(s), I've turned them into integers, etc. I feel like there's something obvious I'm missing.
Here is the code:
ui:
(
uiOutput('variable1selected'),
uiOutput('variable2selected'),
uiOutput("variable3selected")
)
server:
output$variable1selected = renderUI({
checkboxInput("variable1selected",
"Include Variable 1 in Analysis",
value=TRUE)
})
output$variable2selected = renderUI({
checkboxInput("variable2selected",
"Include Variable 2 in Analysis",
value=TRUE)
})
output$variable3selected = renderUI({
checkboxInput("variable3selected",
"Include Variable 3 in Analysis",
value=TRUE)
})
variable1selected = reactive({as.integer(input$variable1selected)})
variable2selected = reactive({as.integer(input$variable2selected)})
variable3selected = reactive({as.integer(input$variable3selected)})
Score = variable1selected()*10 + variable2selected()*20 +
variable3selected()*30
There aren't any error messages, it's just not scoring at all when the checkboxInput is selected. I'm expecting a score for each row, and then I sort the table by that score. What's actually being produced is an unsorted table because there is no score present to sort (the "Score" variable is NA for each row).
Aucun commentaire:
Enregistrer un commentaire