1

更新:我在这里发布了一个相关问题

我需要使用 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)
4

1 回答 1

0

Just getting a chance to dig into this, and the error I am getting is with the window.buildTabsets() from these lines.

Fix in YAML

If I render using these yaml options to disable the bootstrap, I get the expected result, but we lose bootstrap.

--- 
title: "test"
author: "me"
date: '`r Sys.Date()`'
output:
  html_document:
    theme: null
    mathjax: null
---

Confirm?

If possible, will you please verify that this also works on your side?

Better Approach?

In general, I would recommend a different approach, since the rendered html will contain all dependencies, and will be a very large file that gets passed across the websocket. Perhaps, this issue can help describe a potentially better approach.

于 2016-08-25T11:26:43.267 回答