在 Rmarkdown 中保存 Navbar Shiny App
Saving a Navbar Shiny App In Rmarkdown
我正在尝试将 Rmarkdown 文件中的 Shiny 应用保存为独立的 HTML 页面。
我可以用一个简单的 DT::datatable():
---
title: "Test4"
runtime: shiny
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
```{r t4, echo=FALSE, message=FALSE, echo=FALSE}
DT::datatable(iris)
接着是
rmarkdown::render(input = "Test4.Rmd", output_file = "Test4.html", runtime = "shiny")
为我提供了一个包含鸢尾花数据集的 html 文件,我可以根据需要将其粘贴到文件服务器上。 $Employer
喜欢它,感谢 Joe Cheng 等人为我指出了那个解决方案。
(
另外,Joe Cheng 在 google Shiny 群上发了这个:
如果你只有一个 DT::datatable()
object(称之为 "x"),那么你可以调用 htmlwidgets::saveWidget(x, "filepath.html")
将其保存为 HTML 页面
)
但是,$employer
现在要求我将其中两个以选项卡格式放在一起。
当我使用此代码时,如果我使用 RStudio 中的 "Run Document",Rmd 页面会正确呈现:
---
title: "Test3"
runtime: shiny
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
## Embedded Application
Test To Try and Render This Out As Standalone Tabbed Shiny App With Two DT::Dataframes.
```{r tabsets, echo=FALSE, warning=FALSE, message=FALSE}
shinyApp(
ui <- (
navbarPage(
title = 'Testing Saving Shiny',
tabPanel('MTCars', DT::dataTableOutput('mtcarz')) ,
tabPanel('Irises', DT::dataTableOutput('iriz'))
)
)
,
server <- (function(input, output) {
output$mtcarz <- DT::renderDataTable({
DT::datatable(
mtcars,
escape = FALSE,
rownames = FALSE,
options = list(
pageLength = 25,
autoWidth = TRUE
)
)
})
output$iriz <- DT::renderDataTable({
DT::datatable(
iris,
escape = FALSE,
rownames = FALSE,
options = list(
pageLength = 25,
autoWidth = TRUE
)
)
})
})
)
```
但是当我在上面使用 rmarkdown::render 时,HTML 页面给了我预期的框架(标题等),但是 tabs/dataframes 的 none在里面。
我正在使用 DT v.1、rmarkdown v.0.9.2 和 shiny v.0.12.2 以及 R 3.2.1。
我可能遗漏了一些东西,但我不知道 Shiny
应用程序可以在没有 Shiny
服务器的情况下运行。这会是动态的吗?如果没有,你可以这样做。
```{r echo = FALSE, warning = FALSE}
library(shiny)
navbarPage(
title = 'Testing Saving Shiny',
tabPanel('MTCars', DT::datatable(
mtcars,
escape = FALSE,
rownames = FALSE,
options = list(
pageLength = 25,
autoWidth = TRUE
)
)),
tabPanel('Irises', DT::datatable(
iris,
escape = FALSE,
rownames = FALSE,
options = list(
pageLength = 25,
autoWidth = TRUE
)
))
)
```
我正在尝试将 Rmarkdown 文件中的 Shiny 应用保存为独立的 HTML 页面。
我可以用一个简单的 DT::datatable():
---
title: "Test4"
runtime: shiny
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
```{r t4, echo=FALSE, message=FALSE, echo=FALSE}
DT::datatable(iris)
接着是
rmarkdown::render(input = "Test4.Rmd", output_file = "Test4.html", runtime = "shiny")
为我提供了一个包含鸢尾花数据集的 html 文件,我可以根据需要将其粘贴到文件服务器上。 $Employer
喜欢它,感谢 Joe Cheng 等人为我指出了那个解决方案。
(
另外,Joe Cheng 在 google Shiny 群上发了这个:
如果你只有一个 DT::datatable()
object(称之为 "x"),那么你可以调用 htmlwidgets::saveWidget(x, "filepath.html")
将其保存为 HTML 页面
)
但是,$employer
现在要求我将其中两个以选项卡格式放在一起。
当我使用此代码时,如果我使用 RStudio 中的 "Run Document",Rmd 页面会正确呈现:
---
title: "Test3"
runtime: shiny
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
## Embedded Application
Test To Try and Render This Out As Standalone Tabbed Shiny App With Two DT::Dataframes.
```{r tabsets, echo=FALSE, warning=FALSE, message=FALSE}
shinyApp(
ui <- (
navbarPage(
title = 'Testing Saving Shiny',
tabPanel('MTCars', DT::dataTableOutput('mtcarz')) ,
tabPanel('Irises', DT::dataTableOutput('iriz'))
)
)
,
server <- (function(input, output) {
output$mtcarz <- DT::renderDataTable({
DT::datatable(
mtcars,
escape = FALSE,
rownames = FALSE,
options = list(
pageLength = 25,
autoWidth = TRUE
)
)
})
output$iriz <- DT::renderDataTable({
DT::datatable(
iris,
escape = FALSE,
rownames = FALSE,
options = list(
pageLength = 25,
autoWidth = TRUE
)
)
})
})
)
```
但是当我在上面使用 rmarkdown::render 时,HTML 页面给了我预期的框架(标题等),但是 tabs/dataframes 的 none在里面。
我正在使用 DT v.1、rmarkdown v.0.9.2 和 shiny v.0.12.2 以及 R 3.2.1。
我可能遗漏了一些东西,但我不知道 Shiny
应用程序可以在没有 Shiny
服务器的情况下运行。这会是动态的吗?如果没有,你可以这样做。
```{r echo = FALSE, warning = FALSE}
library(shiny)
navbarPage(
title = 'Testing Saving Shiny',
tabPanel('MTCars', DT::datatable(
mtcars,
escape = FALSE,
rownames = FALSE,
options = list(
pageLength = 25,
autoWidth = TRUE
)
)),
tabPanel('Irises', DT::datatable(
iris,
escape = FALSE,
rownames = FALSE,
options = list(
pageLength = 25,
autoWidth = TRUE
)
))
)
```