rstudio/shiny — pull request #512 by yihui (2014-06-12 05:01:53+00:00)
Title: Inline output in R Markdown documents

This PR adds an `inline` argument to four output functions: textOutput(), imageOutput(), plotOutput(), and htmlOutput(), to make it possible to write output to `` instead of `

`.

Here is a test document: https://yihui.shinyapps.io/shiny-inline/

---
title: "Inline Output"
runtime: shiny
output: html_document
---

You can embed Shiny inputs and outputs in your document. Outputs are
automatically updated whenever inputs change. This demonstrates how a standard R
plot can be made interactive by wrapping it in the Shiny `renderPlot()`
function. The `selectInput()` and `sliderInput()` functions create the input
widgets used to drive the plot.

```{r tidy=FALSE}
sidebarLayout(
sidebarPanel(
selectizeInput('main', 'Main title', LETTERS),
sliderInput('size', 'Point size', min = 0.2, max = 5, value = 1)
),
mainPanel(
renderPlot(plot(cars, main = input$main, cex = input$size, pch = 19),
width = 600, height = 400)
)
)
sunsplots_line = function() {
par(mar = rep(0, 4))
plot(sunspots, axes=FALSE, ann=FALSE, asp=input$asp)
}
```

The main title is `r renderText(input$main)` and the point size is `r renderText(input$size)`.

Besides `renderText()`, you can also embed some other output elements inline.

For example, here is a spark line `r renderPlot({sunsplots_line()}, width=300, height=40)`
that shows you the time series `sunspots`.

```{r}
sliderInput('asp', 'Aspect ratio', .02, .3, .2)
```