Not sure what is wrong with the below code, when I try to change the changes the values in "Change to" section the table is not getting updated.Is there way to change the table as we changes the text in "Change to"? Can anyone guide me on this?
library(shiny)
library(DT)
ui <- navbarPage(
"Application",
tabPanel("General",
sidebarLayout(
sidebarPanel(
uiOutput("tex2"),
uiOutput("book3"),
uiOutput("book6")
),
mainPanel(
DT::dataTableOutput("hot3")
)
)))
#server.r
server <- function(input, output,session) {
output$tex2<-renderUI({
numericInput("text2", "#tests", value = 1, min=1)
})
output$book3<-renderUI({
selectInput("bk3", "Label", choices=(paste("Test",1:input$text2)))
})
output$book6<-renderUI({
textInput("bk6", "Change to", value=NULL)
})
df_reactive <- reactiveValues()
rt4 <- reactive({
df_reactive$DF <- data.frame(
Test=paste(1:input$text2),
Label=paste("Test",1:input$text2),
stringsAsFactors = FALSE)
if(!is.null(input$bk6) && input$bk6!=""){
df_reactive$DF[df_reactive$DF$Label==isolate(input$bk3), "Label"] <- input$bk6
}
{
df_reactive$DF
}
})
output$hot3 <-DT::renderDataTable(
rt4(),
rownames= FALSE
)
}
shinyApp(ui, server)