You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Flexdashboard浏览器运行报错‘Object not found’问题求助

问题排查:Flexdashboard加载外部脚本后浏览器运行报“Object not found”错误

我曾参考Stack Overflow相关内容解决过类似问题,现完整复现代码以便排查:

  • 直接在R Markdown内创建数据框的Flexdashboard代码可正常运行,实现侧边栏根据selectInput选择渲染对应输出;
  • 将数据框移至外部R脚本(Scripts/DataMunge.R),通过source加载的版本,本地模拟器运行正常,但在浏览器中运行时出现**‘Object not found’**错误。

本地数据框版本代码

---
title: "FOO"
output: flexdashboard::flex_dashboard
runtime: shiny
---

```{r global, include=FALSE}
Partner <- c("Google", "Microsoft", "Apple","Amazon")
ContactPerson <- c("Andrew","Mary","John","Barbara")
DF <- data.frame(Partner, ContactPerson)

# Create a variable called Partner Organisation
PartnerOrg <- DF$Partner

Column {.sidebar}

selectInput(
  "Select", label = h5("Select partner organisation"), 
  choices = PartnerOrg
)
verbatimTextOutput("value")
output$value <- renderText({ 
  subset(DF, Partner %in% input$Select, "ContactPerson", drop = TRUE)
})
## 加载外部脚本版本代码
```r
---
title: "FOO"
output: flexdashboard::flex_dashboard
runtime: shiny
---

```{r global, include=FALSE}

# sys.source("Scripts/DataMunge.R", envir = knitr::knit_global())
source("Scripts/DataMunge.R", local = knitr::knit_global())

Column {.sidebar}

selectInput(
  "Select", label = h5("Select partner organisation"), 
  choices = PartnerOrg
)
verbatimTextOutput("value")
output$value <- renderText({ 
  subset(DF, Partner %in% input$Select, "ContactPerson", drop = TRUE)
})
## 外部R脚本(Scripts/DataMunge.R)代码
```r
library(tidyverse)
library(ggthemes)
library(RColorBrewer)
library(wesanderson)
library(rsconnect)

Partner <- c("Google", "Microsoft", "Apple","Amazon")
ContactPerson <- c("Andrew","Mary","John","Barbara")
DF <- data.frame(Partner, ContactPerson)

# Create a variable called Partner Organisation
PartnerOrg <- DF$Partner

请问出现该错误的原因是什么?


内容的提问来源于stack exchange,提问作者andrew

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.17 21:46:06