【发布时间】:2016-12-25 17:59:57
【问题描述】:
更新:我发布了一个相关问题here
我需要使用 includeHTML 在闪亮中包含一个 html 文件。该文件由rmarkdown生成,有大量的htmlWidget。
Shiny 正在显示 html 文件,但缺少 htmlWidgests。 仅当 includeHTML 在 server.R 中时才会出现此问题,但如果 includeHTLM 在 ui.R 中则可以正常工作。我需要更新 file.html,因此 includeHTML 必须在反应式上下文中使用。
file.rmd 是这样的
---
title: "test"
author: "me"
date: '`r Sys.Date()`'
output: html_document
---
```{r}
df<- data.frame(a = c(1:10), b = c(1:10))
rpivotTable::rpivotTable(df , rows = 'a' , cols= 'b' )
rpivotTable::rpivotTable(df , rows = 'a' , cols= 'b' )
rpivotTable::rpivotTable(df , rows = 'a' , cols= 'b' )
```
然后渲染到file.html
rmarkdown::render( input = 'file.RMD' )
这个闪亮的应用还可以
ui <- shinyUI(
fluidPage(
includeHTML('file.html')
)
)
server <- function(input, output) { }
shinyApp(ui, server)
但是这个不起作用。
ui <- shinyUI(
fluidPage(
uiOutput('tables')
)
)
server <- shinyServer(function(input, output) {
output$tables <- shiny::renderUI(
includeHTML('file.html')
)
})
shinyApp(ui, server)
【问题讨论】:
-
你能再检查一下吗?它实际上对我有用。
-
也许我们使用了不同版本的闪亮?我正在使用 v‘0.13.2’。以防万一我将所有软件包更新到最新版本,仍然不适合我。如果使用 PNG 呈现 html 文件,它也可以工作,但在呈现 javascript htmlWidgets 时它会失败。
-
我在浏览器控制台中收到这些错误:data:application/x-javascript;base64,KGZ1bwCg==?_=14715.. 44615229 无法加载资源:net::ERR_INVALID_URL
-
对不起,我用不同的 file.html 检查了闪亮的代码
-
我猜依赖没有被转移或者没有被接受。你知道你会提前使用哪个
htmlwidgets吗?例如,你知道你只会创建rpivotTable吗?如果是这样,我们可以提前指定这些。
标签: r shiny r-markdown htmlwidgets