I have this table in my shiny application.
| a | 2 |
| b | 3 |
| c | 5 |
It has a box to choose a line (from 1 to 3), and from there it starts the value referring to that line.
It also has another box so I can change that value. But the numericInput()
function asks for an initial value, so when I select some line it will already change the output to the initial value.
I just want this value to change only if I change the value in the numericInput()
box. I can set the initial value to a negative value and put a if()
but I do not want it that way.
Here's 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