premier commit
This commit is contained in:
commit
e4c90bb95c
3 changed files with 150 additions and 0 deletions
25
LICENSE
Normal file
25
LICENSE
Normal file
|
@ -0,0 +1,25 @@
|
|||
Copyright (c) 2015 François Pelletier
|
||||
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
|
||||
|
16
facebook-key-metrics.Rproj
Normal file
16
facebook-key-metrics.Rproj
Normal file
|
@ -0,0 +1,16 @@
|
|||
Version: 1.0
|
||||
|
||||
RestoreWorkspace: Default
|
||||
SaveWorkspace: Default
|
||||
AlwaysSaveHistory: Default
|
||||
|
||||
EnableCodeIndexing: Yes
|
||||
UseSpacesForTab: Yes
|
||||
NumSpacesForTab: 2
|
||||
Encoding: UTF-8
|
||||
|
||||
RnwWeave: Sweave
|
||||
LaTeX: pdfLaTeX
|
||||
|
||||
AutoAppendNewline: Yes
|
||||
StripTrailingWhitespace: Yes
|
109
key_metrics.Rmd
Normal file
109
key_metrics.Rmd
Normal file
|
@ -0,0 +1,109 @@
|
|||
---
|
||||
title: "Facebook Key Metrics Analysis"
|
||||
author: "François Pelletier"
|
||||
date: "7 novembre 2015"
|
||||
output:
|
||||
html_document:
|
||||
highlight: tango
|
||||
keep_md: yes
|
||||
theme: cerulean
|
||||
toc: yes
|
||||
pdf_document:
|
||||
toc: yes
|
||||
---
|
||||
|
||||
```{r}
|
||||
library(data.table)
|
||||
library(lubridate)
|
||||
library(magrittr)
|
||||
library(ggplot2)
|
||||
library(dplyr)
|
||||
|
||||
# Setup your own Facebook key metrics here (csv export from XLS file)
|
||||
page_key_metrics_raw <- fread("page_key_metrics.csv",header = TRUE)
|
||||
page_key_metrics_raw$Posted2 <- page_key_metrics_raw$Posted %>%
|
||||
lubridate::parse_date_time("m/d/yR")
|
||||
page_key_metrics_raw$substr_post <- page_key_metrics_raw$`Post Message` %>% substr(0,70)
|
||||
```
|
||||
|
||||
## Reach
|
||||
|
||||
```{r, dev='CairoPNG'}
|
||||
ggplot(data=page_key_metrics_raw,
|
||||
aes(x=Posted2,
|
||||
y=`Lifetime Post organic reach`,
|
||||
color=Type)) +
|
||||
geom_line() +
|
||||
ggtitle("Lifetime Post Organic Reach over time by type") +
|
||||
ggplot2::xlab("Time posted")
|
||||
```
|
||||
|
||||
```{r results='asis'}
|
||||
page_key_metrics_raw[order(page_key_metrics_raw$`Lifetime Post organic reach`,
|
||||
decreasing = TRUE),
|
||||
.(substr_post,Permalink,Posted2,`Lifetime Post organic reach`)] %>%
|
||||
head(10) %>% pander::pander()
|
||||
```
|
||||
|
||||
|
||||
|
||||
## Impressions
|
||||
|
||||
```{r, dev='CairoPNG'}
|
||||
ggplot(data=page_key_metrics_raw,
|
||||
aes(x=Posted2,
|
||||
y=`Lifetime Post Organic Impressions`,
|
||||
color=Type)) +
|
||||
geom_line() +
|
||||
ggtitle("Lifetime Post Organic Impressions over time by type") +
|
||||
ggplot2::xlab("Time posted")
|
||||
```
|
||||
|
||||
```{r results='asis'}
|
||||
page_key_metrics_raw[order(page_key_metrics_raw$`Lifetime Post Organic Impressions`,
|
||||
decreasing = TRUE),
|
||||
.(substr_post,Permalink,Posted2,`Lifetime Post Organic Impressions`)] %>%
|
||||
head(10) %>% pander::pander()
|
||||
```
|
||||
|
||||
## Engaged Users
|
||||
|
||||
```{r, dev='CairoPNG'}
|
||||
# correction
|
||||
page_key_metrics_raw$`Lifetime Engaged Users` <-
|
||||
page_key_metrics_raw$`Lifetime Engaged Users` %>% as.numeric
|
||||
|
||||
ggplot(data=page_key_metrics_raw,
|
||||
aes(x=Posted2,
|
||||
y=`Lifetime Engaged Users`,
|
||||
color=Type)) +
|
||||
geom_line() +
|
||||
ggtitle("Lifetime Engaged Users over time by type") +
|
||||
ggplot2::xlab("Time posted")
|
||||
```
|
||||
|
||||
```{r results='asis'}
|
||||
page_key_metrics_raw[order(page_key_metrics_raw$`Lifetime Engaged Users`,
|
||||
decreasing = TRUE),
|
||||
.(substr_post,Permalink,Posted2,`Lifetime Engaged Users`)] %>%
|
||||
head(10) %>% pander::pander()
|
||||
```
|
||||
|
||||
## Type
|
||||
|
||||
```{r}
|
||||
data_mean_reach <- page_key_metrics_raw[,.(Type,`Lifetime Post organic reach`,Posted2)] %>%
|
||||
mutate(month_posted = lubridate::month(Posted2,label=TRUE)) %>%
|
||||
group_by(Type,month_posted) %>% summarise(mean_reach = mean(`Lifetime Post organic reach`))
|
||||
```
|
||||
|
||||
```{r, dev='CairoPNG'}
|
||||
ggplot(data=data_mean_reach,
|
||||
aes(x=Type,y=mean_reach,fill=Type)) +
|
||||
facet_grid(. ~ month_posted) +
|
||||
geom_bar(stat="identity") +
|
||||
ggtitle("Mean reach by post type by month") +
|
||||
ylab("Mean reach")
|
||||
```
|
||||
|
||||
|
Loading…
Add table
Reference in a new issue