create.union: Create union of all data sources from selected channel

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/create_union.R

Description

This function merges all data tables, which belong to the selected channel, into one dataframe. Different versions of this function are also able to perform some basic calculations on the resulting dataframe.

Usage

1
2
3
4
create.union(channel, export)
create.union.aggregated(channel, export)
create.union.recalculated(channel, export, config)
create.union.mad(channel, export, config)

Arguments

channel

Channel (Facebook, Twitter, Linkedin or codierung) to create a union

export

All exported and processed data

config

Configuration object with processing rules for different export types

Details

Various versions of function create.union are designed to create a meaningful union of different data sources, which belong to the same channel. This family of functions is run in background by function simple.merge as an essential step of creation a complete merged dataframe.
For example, if one wants to merge all data from Facebook channel, one of create.union-family functions is used to aggregate data from FB Unpaid Info, FB Paid Info and FB Video Info.
Function create.union will create a union by simply adding all rows of exports, which belong to the selected channel, and filling non-common columns with missing values.
Function create.union.aggregated will aggregate data by post, as well as put info on total spent budget and paid impressions into corresponding unpaid row.
Function create.union.recalculated recalculates values of specific columns (fb.actions.columns, tw.actions.columns etc.) for the rows from unpaid export, using data from paid export. Recalculations are done on the post (row) level. Please note that it is possible to get negative values here.
Funcion create.union.mad creates an output in the format, used for Bosch Social MAD weekly reporting. Processing includes summing up unpaid and paid data in one column of each type. For example, Impressions = Paid.Impressions + Unpaid.Impressions.

Value

Resulting dataframe output is used to create a final result of simple.merge function.

Author(s)

Diana Omelianchyk

See Also

simple.merge

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
##-- See below how this function is used in function simple.merge --

 if (recalculate) {
    merge.all <- as.data.frame(rbindlist(lapply(channels, create.union.recalculated, all, config), fill = TRUE))
  } else if (aggregate) {
    merge.all <- as.data.frame(rbindlist(lapply(channels, create.union.aggregated, all), fill = TRUE))
  } else if (mad) {
    merge.all <- as.data.frame(rbindlist(lapply(channels, create.union.mad, all, config), fill = TRUE))
  } else {
    merge.all <- as.data.frame(rbindlist(lapply(channels, create.union, all), fill = TRUE))
  }

omelyanchikd/merger documentation built on July 13, 2017, 6:24 p.m.