-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfacebook EDA.Rmd
38 lines (33 loc) · 1.17 KB
/
facebook EDA.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
---
title: "Exploratory Data Analysis of facebook ads"
output: github_document
---
```{r message=FALSE, warning=FALSE}
library(tidyverse, quietly = TRUE); library(readr)
FacebookAds <- read_csv("FacebookAds.csv")
```
Let's have a histogram party and look at some of the fields with numbers and categories.
```{r}
FacebookAds_quant <-
FacebookAds %>%
select(AdID, AdSpend, Impressions, Clicks, CreationDate,
EndDate) %>%
mutate(CreationDate = lubridate::ymd_hms(CreationDate) %>%
lubridate::decimal_date(),
EndDate = lubridate::ymd_hms(EndDate) %>%
lubridate::decimal_date()) %>%
gather(stat, value, -AdID)
ggplot(FacebookAds_quant, aes(value)) +
geom_histogram(bins = 100) +
facet_wrap(~stat, scales = "free")
```
Spend vs. Clicks vs. Impressons
```{r}
FacebookAds %>%
ggplot(aes(AdSpend, Impressions, color = log(Clicks),
label = str_wrap(str_sub(AdText, end = 120)))) +
geom_point(size = 1/2, alpha = 1/2) +
scale_x_continuous(trans = "log10", labels = scales::comma) +
scale_y_continuous(trans = "log10", labels = scales::comma) +
ggrepel::geom_text_repel(data = FacebookAds %>% top_n(5, Impressions), size = 2)
```