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_index
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 = "")
  1. input_index ← 2

    1input_index <- 22controls <- c("slider", "select", "checkbox")
    values this step2input_index
  2. controls ← slider, select, checkbox

    1input_index <- 22controls <- c("slider", "select", "checkbox")3values <- c("10", "north", "TRUE")
    values this stepslider, select, checkboxcontrols
  3. values ← 10, north, TRUE

    2controls <- c("slider", "select", "checkbox")3values <- c("10", "north", "TRUE")4control <- controls[input_index]
    values this step10, north, TRUEvalues
  4. control ← select

    3values <- c("10", "north", "TRUE")4control <- controls[input_index]5value <- values[input_index]
    values this stepselectcontrol2input_index
  5. value ← north

    4control <- controls[input_index]5value <- values[input_index]6label <- paste(control, value, sep = ":")
    values this stepnorthvalue2input_index
  6. label ← select:north

    5value <- values[input_index]6label <- paste(control, value, sep = ":")7cat(label, "\n", sep = "")
    values this stepselect:northlabelselectcontrolnorthvalue
  7. cat(label, " ", sep = "")

    6label <- paste(control, value, sep = ":")7cat(label, "\n", sep = "")
    outputselect:north
    values this stepselect:northlabel
  1. input_index ← 1

    1input_index <- 12controls <- c("slider", "select", "checkbox")
    values this step1input_index
  2. controls ← slider, select, checkbox

    1input_index <- 12controls <- c("slider", "select", "checkbox")3values <- c("10", "north", "TRUE")
    values this stepslider, select, checkboxcontrols
  3. values ← 10, north, TRUE

    2controls <- c("slider", "select", "checkbox")3values <- c("10", "north", "TRUE")4control <- controls[input_index]
    values this step10, north, TRUEvalues
  4. control ← slider

    3values <- c("10", "north", "TRUE")4control <- controls[input_index]5value <- values[input_index]
    values this stepslidercontrol1input_index
  5. value ← 10

    4control <- controls[input_index]5value <- values[input_index]6label <- paste(control, value, sep = ":")
    values this step10value1input_index
  6. label ← slider:10

    5value <- values[input_index]6label <- paste(control, value, sep = ":")7cat(label, "\n", sep = "")
    values this stepslider:10labelslidercontrol10value
  7. cat(label, " ", sep = "")

    6label <- paste(control, value, sep = ":")7cat(label, "\n", sep = "")
    outputslider:10
    values this stepslider:10label
  1. input_index ← 3

    1input_index <- 32controls <- c("slider", "select", "checkbox")
    values this step3input_index
  2. controls ← slider, select, checkbox

    1input_index <- 32controls <- c("slider", "select", "checkbox")3values <- c("10", "north", "TRUE")
    values this stepslider, select, checkboxcontrols
  3. values ← 10, north, TRUE

    2controls <- c("slider", "select", "checkbox")3values <- c("10", "north", "TRUE")4control <- controls[input_index]
    values this step10, north, TRUEvalues
  4. control ← checkbox

    3values <- c("10", "north", "TRUE")4control <- controls[input_index]5value <- values[input_index]
    values this stepcheckboxcontrol3input_index
  5. value ← TRUE

    4control <- controls[input_index]5value <- values[input_index]6label <- paste(control, value, sep = ":")
    values this stepTRUEvalue3input_index
  6. label ← checkbox:TRUE

    5value <- values[input_index]6label <- paste(control, value, sep = ":")7cat(label, "\n", sep = "")
    values this stepcheckbox:TRUElabelcheckboxcontrolTRUEvalue
  7. cat(label, " ", sep = "")

    6label <- paste(control, value, sep = ":")7cat(label, "\n", sep = "")
    outputcheckbox:TRUE
    values 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.