/
crosstalk01.Rmd
67 lines (53 loc) · 1.31 KB
/
crosstalk01.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
---
title: "Independent Widgets"
output:
flexdashboard::flex_dashboard:
orientation: rows
source_code: embed
social: [ "twitter", "facebook", "menu" ]
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
library(tidyverse)
library(leaflet)
library(DT)
library(plotly)
```
```{r data}
# load example data
df <- read_csv("example.csv")
# clean example data
df <-
df %>%
filter(!is.na(officer)) %>%
filter(status != "Not a Prospect") %>%
select(name, class, constituency, connection, status, priority, cap16, officer, latitude, longitude)
```
Row
-------------------------------------
### Map
```{r map}
df %>%
leaflet() %>%
addProviderTiles("CartoDB") %>%
addCircleMarkers(popup = ~name)
```
### Chart
```{r plot}
plot_ly(df, x = ~status) %>% add_histogram()
```
Row
-------------------------------------
### Table
```{r table}
datatable(df, extensions= c('Buttons', "Scroller"),
class="compact", width="100%", rownames = FALSE,
options=list(
dom = 'Blfrtip',
deferRender=TRUE,
scrollY=300,
scroller=TRUE,
columnDefs = list(list(visible=FALSE, targets=c(8, 9))),
buttons = list(I('colvis'), 'csv', 'excel'))) %>%
formatCurrency('cap16', digits = 0)
```