---
title: "Crosstalk"
output:
flexdashboard::flex_dashboard:
orientation: rows
source_code: embed
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
# load packages
library(tidyverse)
library(leaflet)
library(DT)
library(plotly)
library(crosstalk)
```
```{r data}
# load example data
df <- read_csv("https://raw.githubusercontent.com/majerus/NEDRA2018/master/example.csv")
# clean example data
df <-
df %>%
filter(officer %in% c("Gaytan, Ivan",
"Spencer, Ruby",
"Center, Victoria")) %>%
select(name, class, constituency, connection, status,
priority, cap16, officer, latitude, longitude)
# Wrap data in SharedData to use with crosstalk
sd <- SharedData$new(df)
```
Inputs {.sidebar}
-------------------------------------
```{r filters}
# Filter input - Officer
filter_select(id = "officer",
label = "Select Gift Officer(s)",
sharedData = sd,
group = ~officer)
```
Row
-------------------------------------
### Map
```{r map}
sd %>%
leaflet() %>%
addTiles() %>%
addCircleMarkers(radius = 2,
label = ~name)
```
Row
-------------------------------------
### Table
```{r table}
sd %>%
datatable(rownames = FALSE) %>%
formatCurrency('cap16',
digits = 0)
```