3
I have this table in my Shiny app.
| a | 2 |
| b | 3 |
| c | 5 |
Has a box to choose a line (from 1 to 3), and from this it prints the value for that line.
There is also another box so I can change this value. Only the function numericInput()
asks for an initial value, so when I select a line it already changes the output to the initial value.
Only that I want that value to change only if I change the value in the numericInput()
. I can set the initial value to a negative value and put a if()
but I don’t want it that way.
Here the example:
library('shiny')
ui <- fluidPage(
numericInput('line', 'Line Choice:', value = 1, min = 1, max = 3),
numericInput('number', 'Value Choice:', value = 0),
textOutput('text')
)
server <- function(input, output) {
observe({
df <- data.frame(c('a', 'b', 'c'), c(2, 3, 5))
output$text <- renderText({
i <- input$line
df[i,2] <- input$number
paste0(df[i,1], ': ', df[i, 2])
})
})
}
shinyApp(ui, server)
Thank you
Thanks Falbel! .
– TheBiro
Good!! These things are annoying in Shiny... In the end you end up generating almost all inputs directly on the server
– Daniel Falbel