在 R 闪亮仪表板中找不到对象“输出”

问题描述 投票:0回答:1

我不断收到此错误:

从第 30-65 行退出 [unnamed-chunk-3] (Dashboard.qmd) 错误: !找不到对象“输出”

执行停止

我正在使用以下代码:

#| context: server
#| include: false

approval <- reactive({asylum_decisions %>%
mutate(approved=
     dec_recognized+dec_other) %>%
filter(year=c("2013","2014","2015","2016","2017","2018","2019","2020","2021","2022"))
left_join(countries_2, join_by(coo_name)) %>%
group_by(year,input$unhcr_region)

})

output$data <- renderTable({approval})

output$plot <- renderPlot({
p <- ggplot(approval,
   aes(x = year,
       y = approved,
       fill = approved)) +
    geom_col() +
    theme_unhcr()
 })
r shiny visualization shinydashboard
1个回答
0
投票

我们需要查看您的更多设置才能完全确定,但从您发布的内容来看,@YBS 提供的评论中包含一种可能的解决方案。

使用之前创建的反应变量时,您需要的格式为

reactive_var()

如果没有

()
,它将无法工作。

#| context: server
#| include: false

approval <- reactive({asylum_decisions %>%
mutate(approved=
     dec_recognized+dec_other) %>%
filter(year=c("2013","2014","2015","2016","2017","2018","2019","2020","2021","2022"))
left_join(countries_2, join_by(coo_name)) %>%
group_by(year,input$unhcr_region)

})

output$data <- renderTable({approval()})

output$plot <- renderPlot({
p <- ggplot(approval(),
   aes(x = year,
       y = approved,
       fill = approved)) +
    geom_col() +
    theme_unhcr()
 })
© www.soinside.com 2019 - 2024. All rights reserved.