【问题标题】:Flex dashboard: Input and Outputs in different tabsFlex 仪表板:不同选项卡中的输入和输出
【发布时间】:2017-04-10 06:51:32
【问题描述】:

我是 flex-dashboards 的新手... 如何在两个不同的选项卡中分离输入信息和输出结果?这是一个简单的例子,我试图在第二个选项卡“输出”中只渲染条形图

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

【问题讨论】:

  • 这是 flex_dashboard,不是 shinydashboard
  • 已编辑问题

标签: r dashboard


【解决方案1】:

你忘记了关于 ui 和服务器函数的所有内容,并像这样直接将对象放入夹盘中:

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

```

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-03-07
  • 1970-01-01
  • 1970-01-01
  • 2021-01-08
  • 2023-03-20
  • 2023-03-13
相关资源
最近更新 更多