flexdashboard: Shiny Embedding

# load data in 'global' chunk so it can be shared by all users of the dashboard
library(datasets)
data(WorldPhones)

Module

Embedding a Shiny Module

# 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(NA, 1), 
    inputPanel(
      selectInput(ns("region"), "Region:", choices = colnames(WorldPhones))
    ),
    plotOutput(ns("phonePlot"), height = "100%")
  )
}

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

Inline App

Inline Shiny App via shinyApp

shinyApp(
  ui = fillPage(
    fillCol(flex = c(NA, 1), 
      inputPanel(
        selectInput("region", "Region:", choices = colnames(WorldPhones))
      ),
      plotOutput("phonePlot", height = "100%")
    )
  ),
  server = function(input, output) {
    output$phonePlot <- renderPlot({
      barplot(WorldPhones[,input$region]*1000, 
              ylab = "Number of Telephones", xlab = "Year")
    })
  },
  options = list(height = 600)
)

External App

External Shiny App via shinyAppDir

shinyAppDir(
  system.file("examples/06_tabsets", package="shiny"),
  options = list(height=850)
)


Try the flexdashboard package in your browser

Any scripts or data that you put into this service are public.

flexdashboard documentation built on July 8, 2020, 7:32 p.m.