I'm just a newbie in using Shiny.
I'm trying to use for-loops to dynamically produce outputs. But, strangely, the loop doesn't work as I expected.
ui <- fluidPage(
p("OUT1"),
textOutput(outputId="OUT1"),
p("OUT2"),
textOutput(outputId="OUT2"),
p("OUT3"),
textOutput(outputId="OUT3")
)
server <- function(input, output, session) {
for (i in 1:3) {
outputId <- paste0("OUT",i)
output[[outputId]] <- renderPrint(i)
}
}
I expected that output slots will contain sequential numbers like 1, 2, 3, but the actual result lists all the same value (=3) for each output slot.
Result of the above code:
OUT1
[1] 3
OUT2
[1] 3
OUT3
[1] 3
I cannot understand what is happening here.
Thanks for your kind answer...