In Shiny App, I want to read a table from my local, display it as an rhandsontable, and overwrite one of the columns with Sys.Date()
, and display the updated table as rhandsontable.
the table function_table
looks like this.
client fun agency loading_site last_update_on_DB
IKEA mean NA Paris 2018-08-01
Nestle sum NA Berlin 2018-08-02
Toyota mean NA Munich 2018-07-01
: : : : :
Here is my server.R
# read a table
func_path <- '/...[FILE PASS].../function_table.csv'
function_table <- reactive({read.csv(func_path, header = T, sep = ',', stringsAsFactors = F)})
# convert table to rhandsontable object to display in the app
hot_func <- reactive({function_table() %>%
rhandsontable(width = 1000, height = 1000) %>%
hot_cols(readOnly = T) %>%
hot_table(stretchH = "all" )})
# do some computations and overwrites the table
# ui.R has an action button (id = compute)
observeEvent({
input$compute
},{
# some computations...
# overwrite last_update_on_DB column with Sys.Date()
function_table()[function_table()$client == input$client,]$last_update_on_DB <- Sys.Date()
})
But the error reads:
Reactives: invalid (NULL) left side of assignment
I also followed this page like below, but got another error:
# read a table
values <- reactiveValues()
func_path <- '/...[FILE PASS].../function_table.csv'
values$function_table <- reactive({read.csv(func_path, header = T, sep = ',', stringsAsFactors = F)})
# convert table to rhandsontable object to display in the app
hot_func <- reactive({values$function_table() %>%
rhandsontable(width = 1000, height = 1000) %>%
hot_cols(readOnly = T) %>%
hot_table(stretchH = "all" )})
# do some computations and overwrites the table
# ui.R has an action button (id = compute)
observeEvent({
input$compute
},{
# some computations...
# overwrite last_update_on_DB column with Sys.Date()
values$function_table <- values$function_table()
values$function_table[values$function_table$client == input$client, ]$last_update_on_DB <- Sys.Date()
})
Warning: Error in eval: tentative d'appliquer un objet qui n'est pas une fonction
(it's telling me that in the line of hot_func, values$function_table() is not a function)
Any solutions?