我正在R中构建一个Shiny App,我正在尝试为反应对象分配一个反应函数 . 但我收到错误,我不知道如何解决这个问题 .

我的服务器.R是,

path_group  <- '/home/makoto/shinyFiles/custom/groups/'
group_livre <- reactive({paste0(path_group, input$client,'.csv')})


# getFilterExport is a function that I made. 
# It fetches a list of data frames.
# The list contains four data frames including $affrete.

list_attribute <- reactive({getFilterExport(connectionDb, input$client)})


# renaming is a data frame with two columns($Name and $Paired)
renaming <- reactive({read.csv(group_livre(), 
                             header = T, sep = ';', 
                             stringsAsFactors = F )[,1:2]})


# Replace the values in list_attribute()$affrete to renaming$Name
# only when it matches renaming$Paired
affrete <- reactive({
    plyr::mapvalues(x = unlist(list_attribute()$affrete, use.names = F),
                               from = as.character(renaming()$Paired),
                               to = as.character(renaming()$Name))
})

list_attribute()$affrete$affrete <- reactive({affrete()})
liste_trans <- reactive({list_attribute()$affrete$affrete})

我得到这种错误:

Error in .getReactiveEnvironment()$currentContext() : 
Operation not allowed without an active reactive context. 
(You tried to do something that can only be done from 
 inside a reactive expression or observer.)

来自ui.R端的输入仅为 input$client ,此输入重新激活 group_livrelist_attributerenamingaffretelist_attribute()$affrete$affreteliste_trans . 我一直在玩,哪些是反应性的,哪些不是,但在任何情况下我都会得到或多或少相同的错误 .

基本上我想问的是,

  • 我知道 group_livrelist_attribute 必须是反应函数 . 但是 renamingaffretelist_attribute()$affrete$affreteliste_trans 的其余部分是否也应该是反应函数呢?

  • 调用反应对象时,必须在对象后面添加() . 关于这一点,上面有任何错误吗?如果要将反应函数分配给已经反应的对象,是否允许写入 list_attribute()$affrete()$affrete()

如果有人能帮助我,我将不胜感激!