2016-11-25 1 views
3

Ich bin ein Newby mit Flex-Dashboards ... Wie kann ich in zwei verschiedenen Registerkarten die Eingangsinformationen trennen und Ergebnisse ausgeben? Hier ist ein einfaches Beispiel, versuche ich nur die BarPlot in dem zweiten Registerkarte „Output“Flex-Dashboard: Ein- und Ausgänge in verschiedenen Registerkarten

--- 
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

das ist flex_dashboard, nicht shinydashboard – HubertL

+0

editierte frage – Juanchi

Antwort

3

Sie vergessen alles über ui und Server-Funktionen und setzen direkt Objekte in Futtern wie dies zu machen:

--- 
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

toll! so einfach! – Juanchi

+0

können Sie mir bitte mit diesem http://stackoverflow.com/questions/40852523/r-flexdashboard-site-not-found-after-deploying helfen – Juanchi

Verwandte Themen