【问题标题】:Getting Error object output not found when trying to render shiny flexdashboard from R script尝试从 R 脚本渲染闪亮的 flexdashboard 时找不到错误对象输出
【发布时间】:2021-02-24 20:35:47
【问题描述】:

如果我直接打开文件并单击 R Studio 中的运行文档,我有一个闪亮的 flexdashboard,它运行良好,但是我正在尝试设置一个 R 脚本来运行仪表板。该脚本将找到降价文件并部分运行它,但一旦它到达output$something <- renderUI(...) 之类的内容时总是会抛出错误。错误是

Error in output$select_file <- renderUI({ : object 'output' not found

此问题的测试降价文件是:

---
title: "example"
author: "hamburglar"
output: 
  flexdashboard::flex_dashboard:
    theme: yeti
    orientation: rows
    vertical_layout: fill
runtime: shiny
---

#```{r setup, include=FALSE}

library(flexdashboard)
library(tidyverse)

#```

Home
=======================================================================

Sidebar {.sidebar}
-----------------------------------------------------------------------

> These are some notes

#```{r}

data(iris)
data(cars)
data(CO2)
files <- list(iris=iris, cars=cars, CO2=CO2)

output$select_file <- renderUI({
  selectInput(inputId='file_choice', 
              label='Choose File', 
              choices=names(files)
              )
})

uiOutput("select_file")

#```

Row
-----------------------------------------------------------------------

### Data
#```{r}

renderTable({
  files[[input$file_choice]]
})


#```

并且我尝试使用以下脚本获得相同的结果:

library(flexdashboard)
library(shiny)
library(rmarkdown)

render("path/test_board.Rmd", 
  #output_file="Dashboard.html"
  #flex_dashboard()
  #"flex_dashboard"
)

对于path,我尝试了共享驱动器路径和我的桌面,我尝试了许多不同的参数,我读过这些参数会让渲染函数知道制作一个 flaexdashboard(在渲染中的 cmets功能)。在我所有的尝试中,我都收到错误消息,指出找不到 output 对象。如果有人能提供任何帮助,我将不胜感激。

【问题讨论】:

    标签: r shiny flexdashboard


    【解决方案1】:

    flexdashboard 中,您不需要使用output。做吧:

    ---
    title: "example"
    author: "hamburglar"
    output: 
      flexdashboard::flex_dashboard:
        theme: yeti
        orientation: rows
        vertical_layout: fill
    runtime: shiny
    ---
    
    ```{r setup, include=FALSE}
    
    library(flexdashboard)
    library(tidyverse)
    
    ```
    
    Home
    =======================================================================
    
    Sidebar {.sidebar}
    -----------------------------------------------------------------------
    
    > These are some notes
    
    ```{r}
    
    data(iris)
    data(cars)
    data(CO2)
    files <- list(iris=iris, cars=cars, CO2=CO2)
    
    selectInput(inputId='file_choice', 
                  label='Choose File', 
                  choices=names(files)
                  )
    
    ```
    
    Row
    -----------------------------------------------------------------------
    
    ### Data
    ```{r}
    
    renderTable({
      files[[input$file_choice]]
    })
    
    ```
    

    【讨论】:

    • 嗨@HubertL 感谢您的回复。如果我取出 uiOutput("select_file") 行,当我尝试通过脚本运行时,我会得到同样的错误,现在当我尝试在 R Studio 中运行时,我得到一个错误:错误尝试在 get1index 中选择少于一个元素
    • 同时删除output$select_file &lt;- renderUI({
    • 现在我收到错误:未提供 html_dependency 的路径
    • 您是否删除了# 之前的```
    • 是的。另外我认为这行不通,因为即使我没有将其放在示例中,但我的亚麻板中的某些输入相互依赖,我认为这不适用于您描述的方法。
    猜你喜欢
    • 2015-04-13
    • 2020-06-12
    • 2018-01-25
    • 2019-12-21
    • 1970-01-01
    • 2020-04-04
    • 1970-01-01
    • 1970-01-01
    • 2021-06-19
    相关资源
    最近更新 更多