Skip to content

Unable to save updated data frame as .rds file with below replicated r shiny app #2

@sound118

Description

@sound118

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions