Shiny Concepts Without Runtime
Input State
Choose a Control
A Shiny app keeps user input values in a named input object.
Program
Play the script to choose a modeled input control and see the current value label.
input_state.R
Replay: real traced execution (multi-file project)
input_index <- 2
controls <- c("slider", "select", "checkbox")
values <- c("10", "north", "TRUE")
control <- controls[input_index]
value <- values[input_index]
label <- paste(control, value, sep = ":")
cat(label, "\n", sep = "")
input_index <- 1
controls <- c("slider", "select", "checkbox")
values <- c("10", "north", "TRUE")
control <- controls[input_index]
value <- values[input_index]
label <- paste(control, value, sep = ":")
cat(label, "\n", sep = "")
input_index <- 3
controls <- c("slider", "select", "checkbox")
values <- c("10", "north", "TRUE")
control <- controls[input_index]
value <- values[input_index]
label <- paste(control, value, sep = ":")
cat(label, "\n", sep = "")
input_index ← 2
1input_index <- 22controls <- c("slider", "select", "checkbox")values this step2input_indexcontrols ← slider, select, checkbox
1input_index <- 22controls <- c("slider", "select", "checkbox")3values <- c("10", "north", "TRUE")values this stepslider, select, checkboxcontrolsvalues ← 10, north, TRUE
2controls <- c("slider", "select", "checkbox")3values <- c("10", "north", "TRUE")4control <- controls[input_index]values this step10, north, TRUEvaluescontrol ← select
3values <- c("10", "north", "TRUE")4control <- controls[input_index]5value <- values[input_index]values this stepselectcontrol2input_indexvalue ← north
4control <- controls[input_index]5value <- values[input_index]6label <- paste(control, value, sep = ":")values this stepnorthvalue2input_indexlabel ← select:north
5value <- values[input_index]6label <- paste(control, value, sep = ":")7cat(label, "\n", sep = "")values this stepselect:northlabelselectcontrolnorthvaluecat(label, " ", sep = "")
6label <- paste(control, value, sep = ":")7cat(label, "\n", sep = "")outputselect:northvalues this stepselect:northlabel
input_index ← 1
1input_index <- 12controls <- c("slider", "select", "checkbox")values this step1input_indexcontrols ← slider, select, checkbox
1input_index <- 12controls <- c("slider", "select", "checkbox")3values <- c("10", "north", "TRUE")values this stepslider, select, checkboxcontrolsvalues ← 10, north, TRUE
2controls <- c("slider", "select", "checkbox")3values <- c("10", "north", "TRUE")4control <- controls[input_index]values this step10, north, TRUEvaluescontrol ← slider
3values <- c("10", "north", "TRUE")4control <- controls[input_index]5value <- values[input_index]values this stepslidercontrol1input_indexvalue ← 10
4control <- controls[input_index]5value <- values[input_index]6label <- paste(control, value, sep = ":")values this step10value1input_indexlabel ← slider:10
5value <- values[input_index]6label <- paste(control, value, sep = ":")7cat(label, "\n", sep = "")values this stepslider:10labelslidercontrol10valuecat(label, " ", sep = "")
6label <- paste(control, value, sep = ":")7cat(label, "\n", sep = "")outputslider:10values this stepslider:10label
input_index ← 3
1input_index <- 32controls <- c("slider", "select", "checkbox")values this step3input_indexcontrols ← slider, select, checkbox
1input_index <- 32controls <- c("slider", "select", "checkbox")3values <- c("10", "north", "TRUE")values this stepslider, select, checkboxcontrolsvalues ← 10, north, TRUE
2controls <- c("slider", "select", "checkbox")3values <- c("10", "north", "TRUE")4control <- controls[input_index]values this step10, north, TRUEvaluescontrol ← checkbox
3values <- c("10", "north", "TRUE")4control <- controls[input_index]5value <- values[input_index]values this stepcheckboxcontrol3input_indexvalue ← TRUE
4control <- controls[input_index]5value <- values[input_index]6label <- paste(control, value, sep = ":")values this stepTRUEvalue3input_indexlabel ← checkbox:TRUE
5value <- values[input_index]6label <- paste(control, value, sep = ":")7cat(label, "\n", sep = "")values this stepcheckbox:TRUElabelcheckboxcontrolTRUEvaluecat(label, " ", sep = "")
6label <- paste(control, value, sep = ":")7cat(label, "\n", sep = "")outputcheckbox:TRUEvalues this stepcheckbox:TRUElabel
input state
A modeled input has a control name and a current value.
selection
Indexing vectors lets one small script represent several controls.
label
The label makes the selected input state visible without running Shiny.