使用 flexdashboard 模板重现闪亮

reproducing shiny using flexdashboard template

我从 shinygallery 借用了下面的代码并做了一些修改。基本上这使用 fluidPage。我有兴趣使用 flexdashboard 重做同样的事情。我经历了flexdashboard userguide。 但该网站上的描述采用某种 rmarkdown 或 sweave 格式??我不熟悉。因此,如果我可以看到这个示例的 flexdashboard 版本没有 markdown 或 sweave,那么我可以很容易地与不同的组件相关联并以此为基础进行构建。感谢任何提示或指示。

library(shiny)
ui = shinyUI(fluidPage(
                mainPanel(
                 tabsetPanel(
                   tabPanel("Plot",plotOutput("plot1"),plotOutput("plot2")),
                   tabPanel("Summary",verbatimTextOutput("summary")),
                  tabPanel("Table",DT::dataTableOutput("table"))
                   ))))

server = shinyServer(function(input, output, session) {
  output$plot1 <- renderPlot({
    plot(cars)
  })

  output$plot2 <- renderPlot({
    plot(iris)
  })

  output$summary <- renderPrint({
    summary(cars)
  })

  output$table <- DT::renderDataTable({
    DT::datatable(cars)
  })
})

shinyApp(ui, server)

我很快就把它放在一起了。

不完美。但它通常可以完成工作(而且我必须离开工作,也许我今晚晚些时候会微调)

请注意,在此 post 之前,我也从未遇到过 flexdashboard。我用了很多 shinydashboard,还有 RMarkdown,所以这绝对很有趣。不确定 flexdashboard 对我个人来说会比 shinydashboard 真正增加什么,但我肯定会更多地使用它。

总之...

---
title: "Test App"
output: flexdashboard::flex_dashboard
---

Plot
=====================================  

row 
-------------------------------------


```{r}
library(shiny)
renderPlot({
  plot(cars)
})
```

row 
-------------------------------------

```{r}
renderPlot({
  plot(iris)
})
```   


Summary
=====================================     

```{r}   
renderPrint({
    summary(cars)
  })
```


Table
=====================================     

```{r}   
DT::renderDataTable({
    DT::datatable(cars)
  })
```

一个大问题是,当我调用 row 时,我得到的是一行中的两个图,而不是两个不同的行。我会玩得更远。