Skip to content

Instantly share code, notes, and snippets.

@stephlocke
Created July 14, 2017 16:06
Show Gist options
  • Save stephlocke/4454adb4458f3ffe8ff5f47312238c53 to your computer and use it in GitHub Desktop.
Save stephlocke/4454adb4458f3ffe8ff5f47312238c53 to your computer and use it in GitHub Desktop.
A quick app built showing how to make sliders and interactive charts!
---
title: "Untitled"
output:
flexdashboard::flex_dashboard:
orientation: columns
vertical_layout: fill
runtime: shiny
---
```{r setup, include=FALSE}
library(flexdashboard)
library(ggplot2)
library(plotly)
library(tidyverse)
```
Column {.sidebar}
-----------------------------------------------------------------------
```{r}
sliderInput("rows","Iris rows to select",min = 0, max = nrow(iris), nrow(iris))
checkboxGroupInput("species",
"Within the following species",
unique(iris$Species),
unique(iris$Species))
```
Column {data-width=650}
-----------------------------------------------------------------------
### Chart A
```{r}
renderPlotly({
iris %>%
sample_n(input$rows) %>%
filter(Species %in% input$species) %>%
ggplot(aes(Petal.Length, Petal.Width, colour=Species)) +
geom_point() ->
basicChart
plotly::ggplotly(basicChart)
})
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment