微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

将无功值从控制模块传递到子模块

如何解决将无功值从控制模块传递到子模块

我知道这已经被问过几次了,但我似乎无法将输入值传递给服务器函数我有一个包含 3 个用户输入字段(yearViewcompanyCodecountries)的 UI。我想使用这些输入根据用户选择的内容过滤数据集(dataChunk_DM1,这是一个标题)。我正在尝试使用例如访问它们input$yearView 但 R 抛出错误

Listening on http://127.0.0.1:7849
Warning: Error in : Problem with `filter()` input `..1`.
x Input `..1` must be of size 32887 or 1,not size 0.
i Input `..1` is `format(AUGDT,"%Y") == input$"Control-yearView"`.
  224: <Anonymous>

我知道它没有找到输入值,然后自动NULL。这是我的代码

moduleControlUI <- function(id,...) {
  
  ns <- NS(id)
  fluidRow(
    Box(
      selectInput(
        inputId = ns("yearView"),label = "Year:",choices = daterange
      ),selectInput(
        inputId = ns("companyCode"),label = "Company Code:",choices = c("0008" = "0008","0036" = "0036")
      ),selectInput(
        inputId = ns("countries"),label = "Countries:",choices = countryKeys,selected = countryKeys[1:10],multiple = T
      )
    )
  )
  
}

moduleD1Server <- function(id) {
  
  moduleServer(
    id,function(input,output,session) {
      
      dataFiltered <- reactive({
        dataChunk_DM1 %>% filter(format(AUGDT,"%Y") == input$'Control-yearView',BUKRS == input$'Control-companyCode',CTNKY %in% input$'Control-countries')
      })
      
      data_PTbyCountry <- reactive({
        dataFiltered() %>% filter(GRPMT == "net") %>% 
          group_by(cntkY) %>% summarise(test = sum(INXEP)/sum(INVAM))
      })
      
      output$plot_PTbyCountry <- renderPlot(
        
        ggplot(data_PTbyCountry(),aes(x = cntkY,y = test)) +
          geom_bar(stat = "identity")
        
      )
      
    }
  )
  
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。