Assignment 4 - Tables

Author

Emily Starer

Summary

The data is advertising media data. The data is from actual advertising campaigns. The data is represented in a table to have as a benchmarking documents for future media activation . The table represents different clients across Consideration campaigns. The columns in the table represent different KPIs used to measure media: Impressions, Clicks, CTR, Sales and CVR. I formatted the table to look at one specific tactic and then the rows represent each client so that it is easy to compare tactics across clients.

Input Data Source

Warning: package 'DT' was built under R version 4.1.2
Warning: package 'tidyverse' was built under R version 4.1.2
── Attaching packages ─────────────────────────────────────── tidyverse 1.3.2 ──✔ ggplot2 3.3.5      ✔ purrr   0.3.4 
✔ tibble  3.1.8      ✔ dplyr   1.0.10
✔ tidyr   1.2.1      ✔ stringr 1.4.0 
✔ readr   2.1.3      ✔ forcats 0.5.1 
Warning: package 'tibble' was built under R version 4.1.2
Warning: package 'tidyr' was built under R version 4.1.2
Warning: package 'readr' was built under R version 4.1.2
Warning: package 'dplyr' was built under R version 4.1.2
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag()    masks stats::lag()
Attaching package: 'dbplyr'

The following objects are masked from 'package:dplyr':

    ident, sql
#read in data
library(readr)
media <- read.csv("mediadata.csv") 
head(media)
    Client            Tactic   Imps Clicks  CTR Conversions   Sales
1 Client A     Consideration 122978    148 0.12         914    0.00
2 Client A     NCACONVERSION  13965     32 0.23         179  290.40
3 Client A LOYALTYCONVERSION   6089      3 0.05          32 1218.14
4 Client A     Consideration   2086      1 0.05          17    0.00
5 Client A LOYALTYCONVERSION    344      0 0.00           2    0.00
6 Client A     NCACONVERSION    247      0 0.00          68  192.10

Build Table

#Consideration Table 

#grouping by Consideration Tactic
media_consid <- media %>% filter(media$Tactic == "Consideration")

#aggregate by Client 
media_consid <- media_consid %>% group_by(Client, Tactic) %>%
                                  summarize (Impressions = sum(Imps),
                                             Click = sum(Clicks),
                                             CTR = ((Click / Impressions)*100),
                                             Sales_Conversions = sum(Conversions),
                                             CVR =  ((Sales_Conversions / Impressions)*100))
`summarise()` has grouped output by 'Client'. You can override using the
`.groups` argument.
media_consid
# A tibble: 7 × 7
# Groups:   Client [7]
  Client   Tactic        Impressions Click   CTR Sales_Conversions   CVR
  <chr>    <chr>               <int> <int> <dbl>             <int> <dbl>
1 Client A Consideration      645330  1497 0.232              2650 0.411
2 Client B Consideration      182229   408 0.224               850 0.466
3 Client C Consideration     2660572  4885 0.184              2948 0.111
4 Client D Consideration      498994  2089 0.419              4254 0.853
5 Client F Consideration      106865   345 0.323              1296 1.21 
6 Client G Consideration      326215  5239 1.61               3957 1.21 
7 Client H Consideration      683350  1713 0.251              2918 0.427
tbl_mediac_consid <- media_consid %>%
                    select (Client, Impressions, Click, CTR, Sales_Conversions, CVR) %>%
                    datatable (colnames= c("Client",
                                      "Impressions",
                                       "Clicks",
                                       "CTR",
                                       "Sales",
                                       "CVR"))%>%
                    formatRound(columns = c(2,3,5),
                                          digits = 0)%>%
                    formatPercentage(columns = c(4,6),
                                     digits = 1)

tbl_mediac_consid