reproducing shiny using flexdashboard template

主宰稳场 提交于 2019-12-05 03:28:31

问题


I borrowed this code below from the shinygallery and made some changes. Basically this uses fluidPage. I am interested in redoing the same thing using flexdashboard . I have gone through the flexdashboard userguide. but the descriptions on that website are in some rmarkdown or sweave format ?? which I am not familiar with. So if I can see the flexdashboard version of this example without the markdown or sweave then i can easily relate to different components and build on that. Any tips or pointers are appreciated folks.

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)

回答1:


I quickly put this together.

Not perfect. But it generally gets the job done (and I have to leave work, maybe I'll fine tune later tonight)

Note that I also had never come across flexdashboard before this post. I had used shinydashboard quite a bit, as well as RMarkdown, so this is definitely interesting. Not sure what flexdashboard will really add for me personally over and above shinydashboard, but I'm definitely going to play with it some more.

Anyway...

---
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)
  })
```

The one big issue being that while I'm calling row, I'm getting to the two plots on a single row instead of two different rows. I will play further.



来源:https://stackoverflow.com/questions/37353191/reproducing-shiny-using-flexdashboard-template

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!