在 Shiny App 中,我想从本地读取一个表,将其显示为 rhandsontable,并用 覆盖其中一个列Sys.Date()
,并将更新后的表显示为 rhandsontable。
桌子function_table
看起来像这样。
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
: : : : :
这是我的服务器.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()
})
但错误显示:
反应:赋值左侧无效(NULL)
我也关注了这个页面,如下所示,但出现了另一个错误:
# 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)
有什么解决办法吗?