I got below replication of R shiny app which is simpler version of yours, when run it and edit the last column of iris data frame, the app always give me this error message: Warning: Error in <<-: invalid (NULL) left side of assignment
Could you please help me to debug it? Thanks.
library(shiny)
library(DT)
ui <- fluidPage(
DTOutput("iris_table")
)
server <- function(input, output, session) {
create a reactive copy of iris data frame
iris_data <- reactiveVal(iris)
render the data table with editable option for the last column
output$iris_table <- renderDT({
datatable(iris_data(), editable = list(target = "column", disable = list(columns = c(0:4))))
})
update the iris data frame when the user edits the last column
observeEvent(input$iris_table_cell_edit, {
info <- input$iris_table_cell_edit
str(info)
i <- info$row
j <- info$col
v <- info$value
iris_data()[i, j] <<- DT::coerceValue(v, iris_data()[i, j])
# save the updated iris data frame as iris_updated.rds file in a directory
saveRDS(iris_data(), file = "iris_updated.rds")
})
}
shinyApp(ui, server)
I got below replication of R shiny app which is simpler version of yours, when run it and edit the last column of iris data frame, the app always give me this error message: Warning: Error in <<-: invalid (NULL) left side of assignment
Could you please help me to debug it? Thanks.
library(shiny)
library(DT)
ui <- fluidPage(
DTOutput("iris_table")
)
server <- function(input, output, session) {
create a reactive copy of iris data frame
iris_data <- reactiveVal(iris)
render the data table with editable option for the last column
output$iris_table <- renderDT({
datatable(iris_data(), editable = list(target = "column", disable = list(columns = c(0:4))))
})
update the iris data frame when the user edits the last column
observeEvent(input$iris_table_cell_edit, {
info <- input$iris_table_cell_edit
str(info)
i <- info$row
j <- info$col
v <- info$value
iris_data()[i, j] <<- DT::coerceValue(v, iris_data()[i, j])
})
}
shinyApp(ui, server)