2016-11-25 5 views
3

私はフレックスダッシュボードで新人です... 2つの異なるタブで入力情報と出力結果をどのように分けることができますか?ここでは簡単な例ですが、私は2番目のタブ「出力」フレックスダッシュボード:異なるタブの入力と出力

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

これはflex_dashboardであり、shinydashboardではありません – HubertL

+0

編集済みの質問 – Juanchi

答えて

3

にのみbarplotをレンダリングしようとしているあなたは、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") 
    }) 

``` 
+0

素晴らしい!そう簡単に! – Juanchi

+0

これで私を助けてくれますか?http://stackoverflow.com/questions/40852523/r-flexdashboard-site-not-found-after-deploying – Juanchi

関連する問題