Skip to content

Instantly share code, notes, and snippets.

@bearloga
Created December 4, 2015 19:32
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bearloga/96ac68585e86e84900b7 to your computer and use it in GitHub Desktop.
Save bearloga/96ac68585e86e84900b7 to your computer and use it in GitHub Desktop.
This allows the presenter to write and execute R code within the presentation without going back and forth between the presentation and the R console.
---
title: "Interactive Presentations"
author: "Mikhail Popov (@bearloga)"
date: "December 4, 2015"
output: ioslides_presentation
runtime: shiny
---
## Reduce Demo
`Reduce` uses a binary function to successively combine the elements of a given vector and a possibly given initial value.
```{r}
A <- month.name[2:6] # February, March, April, May, June
B <- month.name[4:10] # April, May, June, July, August, September, October
C <- month.name[3*(1:4)] # March, June, September, December
D <- month.name[2*(1:6)] # February, April, June, August, October, December
```
```{r, echo=FALSE}
inputPanel(
tags$textarea(id = "ex3", rows = 3, cols = 40,
style = "width:700px;font-size:24px;",
'intersect(intersect(intersect(A,B),C),D)')
)
renderPrint({
eval(parse(text = input$ex3))
})
```
<!-- When presenting, replace code in text area with: Reduce(intersect, list(A,B,C,D)) -->
@bearloga
Copy link
Author

bearloga commented Dec 4, 2015

When presenting, replace code in text area with: Reduce(intersect, list(A,B,C,D))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment