3

Is there any way, without using shiny, how to filter the data using html drop down in rMarkdown ioslides_presentation (or some kind of javascript function)?

I have very simple code using mtcars data and html drop down menu. I'd like to filter the mtcars data frame via html drop down, something like mtcars[mtcars$mpg > 'value1'.

Is it possible to do that in rMarkdown ioslides_presentation or there is only way to do that via Shiny reactive programming. Thanks a lot for your advice in advance.

---
date: "`r Sys.Date()`"
output: ioslides_presentation
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

## Slide 1

<div>
<select name="mpgFilter" id="mpgFilter">
<option value="1">mpg > 21</option>
<option value="2">mpg > 18</option>
<option value="3">mpg > 15</option>
</select>
</div>

```{r echo=FALSE}
data("mtcars")
mtcarsData <- mtcars[mtcars$mpg > 21,]
plot(mtcarsData$mpg, mtcarsData$disp)
```
martinkabe
  • 1,079
  • 2
  • 12
  • 27
  • You can include Shiny in your RMardown documents http://rmarkdown.rstudio.com/authoring_shiny.html – Xiongbing Jin Oct 19 '16 at 13:48
  • Yes, I know and this is something I don't want to do that :-) – martinkabe Oct 19 '16 at 14:10
  • You can use `DT::datatable` in your slides without shiny, and that has a built in filtering feature. – Carl Oct 19 '16 at 16:00
  • Any ideas, how can I use DT for my example? – martinkabe Oct 19 '16 at 16:52
  • If you want to keep it in JavaScript, then you will need to use `htmlwidgets` or a JavaScript plotting function. See [`crosstalk`](https://github.com/rstudio/crosstalk). If you want assignment back to `R`, then you will need `Shiny` (recommended) or another alternative. – timelyportfolio Oct 20 '16 at 13:04

0 Answers0