Flex 仪表板:不同选项卡中的输入和输出

Jua*_*chi 4 dashboard r

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

\n\n
---\ntitle: "Dashboard"\noutput: \n  flexdashboard::flex_dashboard:\nruntime: shiny\n---\n```{r global, include=FALSE}\n# load data in \'global\' chunk so it can be shared by all users of the dashboard\nlibrary(datasets)\ndata(WorldPhones)\n```\n\nInputs\n=======================================================================\n\n```{r, include=FALSE}\n# Shiny module definition (would typically be defined in a separate R script)\n\n# UI function\nworldPhonesUI <- function(id) {\n  ns <- NS(id)\n  fillCol(height = 600, flex = c(2, 1),\n    inputPanel(\n      selectInput(ns("region"), "Region1:", choices = colnames(WorldPhones))\n    )\n  )\n}\n\n# Server function\nworldPhones <- function(input, output, session) {\n  output$phonePlot <- renderPlot({\n    barplot(WorldPhones[,input$region]*1000, \n            ylab = "Number of Telephones", xlab = "Year")\n  })\n}\n```\n\n```{r, eval=TRUE}\n# Include the module\nworldPhonesUI("phones")\ncallModule(worldPhones, "phones")\n```\n\nResults\n=======================================================================\n\n```{r}\nworldPhonesUI <- function(id) {\n  ns <- NS(id)\n  fillCol(height = 600, flex = c(NA, 1),\n    plotOutput(ns("phonePlot"), height = "80%")\n  )\n}\n```\n
Run Code Online (Sandbox Code Playgroud)\n

Hub*_*rtL 6

你忘记了关于用户界面和服务器功能的一切,直接将对象放入卡盘中,如下所示:

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

```
Run Code Online (Sandbox Code Playgroud)