-
Notifications
You must be signed in to change notification settings - Fork 0
/
dashboard.Rmd
110 lines (99 loc) · 2.84 KB
/
dashboard.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
---
title: "Facebook Ad Manager Data for June 2020"
output:
flexdashboard::flex_dashboard:
orientation: rows
vertical_layout: fill
---
```{r setup, include=FALSE}
library(flexdashboard)
library(tidyverse)
library(plotly)
library(leaflet)
library(maps)
#FB Data Locations for initial import
region_import <- "data/fb_region.csv"
age_import <- "data/fb_age.csv"
gender_import <- "data/fb_gender.csv"
source("src/data_import.R")
#Running data_import function to create tibbles
fb_region <- data_import(region_import)
fb_age <- data_import(age_import)
fb_gender<- data_import(gender_import)
#Preparing Map Data & function
source("src/plots.R")
```
Row
-----------------------------
### Gender Audiences
```{r}
plot_ly(fb_gender,
x = ~Gender,
y = ~Reach,
type = "bar",
mode = "markers",
visible = T) %>%
add_trace(fb_age, y = ~Impressions, visible = F) %>%
add_trace(fb_age, y = ~`CPC (All)`, visible = F) %>%
add_trace(fb_age, y = ~`CTR (All)`, visible = F) %>%
layout(
showlegend=FALSE,
yaxis = list(title = "Metric"),
updatemenus = list(
list(
y = 1,
x = 1,
buttons = list(
list(method = "restyle",
label = "Reach",
args = list("visible", list(TRUE, FALSE, FALSE, FALSE))),
list(method = "restyle",
label = "Impressions",
args = list("visible", list(FALSE, TRUE, FALSE, FALSE))),
list(method = "rstyle",
label = "CPC",
args = list("visible", list(FALSE, FALSE, TRUE, FALSE))),
list(method = "restyle",
label = "CTR",
args = list("visible", list(FALSE, FALSE, FALSE, TRUE)))
))))
```
### Age Audiences
```{r}
plot_ly(fb_age,
x = ~Age,
y = ~Reach,
type = "bar",
mode = "markers",
visible = T) %>%
add_trace(fb_age, y = ~Impressions, visible = F) %>%
add_trace(fb_age, y = ~`CPC (All)`, visible = F) %>%
add_trace(fb_age, y = ~`CTR (All)`, visible = F) %>%
layout(
showlegend=FALSE,
yaxis = list(title = "Metric"),
updatemenus = list(
list(
y = 1,
x = 1,
buttons = list(
list(method = "restyle",
label = "Reach",
args = list("visible", list(TRUE, FALSE, FALSE, FALSE))),
list(method = "restyle",
label = "Impressions",
args = list("visible", list(FALSE, TRUE, FALSE, FALSE))),
list(method = "rstyle",
label = "CPC",
args = list("visible", list(FALSE, FALSE, TRUE, FALSE))),
list(method = "restyle",
label = "CTR",
args = list("visible", list(FALSE, FALSE, FALSE, TRUE)))
))))
```
Row
------------------------------
### Audiences Based on Location
```{r}
fb_map()
```