Skip to content

Instantly share code, notes, and snippets.

@lgatto
Last active August 29, 2015 14:05
Show Gist options
  • Save lgatto/49f0effd0873e0678be6 to your computer and use it in GitHub Desktop.
Save lgatto/49f0effd0873e0678be6 to your computer and use it in GitHub Desktop.
Inline and external apps in Rmd
---
title: " Embedded Shiny Apps"
runtime: shiny
output:
html_document:
theme: united
---
## Setup
```{r}
library("rmarkdown")
library("shiny")
packageVersion("shiny")
packageVersion("rmarkdown")
```
Pandoc version 1.12.4.2.
## Compile vignette
```{r, eval=FALSE}
rmarkdown::run("test.Rmd")
```
## Inline App
```{r, echo = FALSE}
shinyApp(
ui = fluidPage(
selectInput("region", "Region:",
choices = colnames(WorldPhones)),
plotOutput("phonePlot")
),
server = function(input, output) {
output$phonePlot <- renderPlot({
barplot(WorldPhones[,input$region]*1000,
ylab = "Number of Telephones", xlab = "Year")
})
},
options = list(height = 500)
)
```
## External App
```{r, echo = FALSE}
shinyAppDir(
system.file("examples/06_tabsets", package="shiny"),
options=list(
width="100%", height=700
)
)
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment