4

I´m a newby with flex-dashboards... How can I separate in two different tabs the input information and output results? here is a simple example, I am trying to render only the barplot in the second tab "Output"

---
title: "Dashboard"
output: 
  flexdashboard::flex_dashboard:
runtime: shiny
---
```{r global, include=FALSE}
# load data in 'global' chunk so it can be shared by all users of the dashboard
library(datasets)
data(WorldPhones)
```

Inputs
=======================================================================

```{r, include=FALSE}
# Shiny module definition (would typically be defined in a separate R script)

# UI function
worldPhonesUI <- function(id) {
  ns <- NS(id)
  fillCol(height = 600, flex = c(2, 1),
    inputPanel(
      selectInput(ns("region"), "Region1:", choices = colnames(WorldPhones))
    )
  )
}

# Server function
worldPhones <- function(input, output, session) {
  output$phonePlot <- renderPlot({
    barplot(WorldPhones[,input$region]*1000, 
            ylab = "Number of Telephones", xlab = "Year")
  })
}
```

```{r, eval=TRUE}
# Include the module
worldPhonesUI("phones")
callModule(worldPhones, "phones")
```

Results
=======================================================================

```{r}
worldPhonesUI <- function(id) {
  ns <- NS(id)
  fillCol(height = 600, flex = c(NA, 1),
    plotOutput(ns("phonePlot"), height = "80%")
  )
}
```
Juanchi
  • 1,147
  • 2
  • 18
  • 36

1 Answers1

6

you forget everything about ui and server functions and put directly objects in chucks like this:

---
title: "Dashboard"
output: 
  flexdashboard::flex_dashboard:
runtime: shiny
---
```{r global, include=FALSE}
# load data in 'global' chunk so it can be shared by all users of the dashboard
library(datasets)
data(WorldPhones)
```

Inputs
=======================================================================

```{r}

selectInput("region", "Region1:", choices = colnames(WorldPhones))

```

Results
=======================================================================

```{r}
renderPlot({
    barplot(WorldPhones[,input$region]*1000, 
            ylab = "Number of Telephones", xlab = "Year")
  })

```
HubertL
  • 19,246
  • 3
  • 32
  • 51