Skip to content

Instantly share code, notes, and snippets.

@khakieconomics
Created August 28, 2018 19:52
Show Gist options
  • Save khakieconomics/edb70b45bea002f05b278490d85f536f to your computer and use it in GitHub Desktop.
Save khakieconomics/edb70b45bea002f05b278490d85f536f to your computer and use it in GitHub Desktop.
Simple R dashboard with plotly mouse-over effects
---
title: "Demo of mouse-over"
output:
flexdashboard::flex_dashboard:
orientation: columns
vertical_layout: fill
---
```{r setup, include=FALSE}
library(flexdashboard)
```
### Demo chart
```{r}
library(tidyverse); library(plotly); library(ggthemes)
p <- crossing(`Law firm` = LETTERS[1:10], Year = 1990:2018) %>%
group_by(`Law firm`) %>%
mutate(`Profits per partner` = 1e6 + 50000 * (Year - 1990) + cumsum(rnorm(n(), 0, 100000))) %>%
ungroup %>%
ggplot(aes(x = Year, y = `Profits per partner`, group = `Law firm`)) +
geom_line(alpha = 0.6) +
theme_hc()
ggplotly(p)
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment