simple.merge: General function for creating merged files

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

View source: R/simple_merge.R

Description

Wraps all procedures, needed for merging files from different data sources (Facebook, Twitter, Linkedin, Instagram etc.). Different values of parameters create merged file in one of preselected output formats (for example, aggregated or recalculated).

Usage

1
2
3
4
simple.merge(path, config.file, recalculate = FALSE, 
  aggregate = FALSE, codierung = FALSE, 
  create.paid = FALSE, prepare = FALSE, 
  output.file = "MergeAll")

Arguments

path

Path to the folder with files to merge

config.file

Path to the file containing various configurations (name of variables in different types of files)

recalculate

Does one need to recalculate value for any country into other country?

aggregate

Does one need detailed paid data or only budget and impressions?

codierung

Does one need to merge coded files from Akili

create.paid

Does one need to create paid data from Facebook Power Editor and Facebook Ads Manager?

prepare

Does one need just to prepare data for further use in Akili?

output.file

Name of the file where the result would be written in

Details

Function simple.merge is designed to wrap up all extracting, transforming and loading procedures of merged file creation. It calls several low level functions in process. Its goal is to provide the flexibility for users, who should be able to produce different results by selecting different values of function parameters.
The function reads configuration file and creates configuration object, which is used for further procedures. Then it creates a list of different class objects, which are capable of performing similar procedures (methods) on different input types. After that, function reads in the data from the folder, defined by the variable path, and performs various unifying procedures, including fixing content identifiers and content types, restoring permalinks, fixing broken content identifiers, and adding new data columns (for example, 30 second video views) to basic files. Low level functions are also capable to create Facebook Paid Export file from Facebook Ads Manager Export and Facebook Power Editor Export, as well as process files, received from coders.
After standartising all class objects in a list, function performs union procedures and creates aggregate dataframe, depending on preset parameters (basic, recalculated, aggregated etc.).

Value

A data.frame with merged data. Also the function produces an Excel workbook in the folder path with the name output.file, containing data from resulting data.frame.

Author(s)

Diana Omelianchyk

See Also

read.file

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
# Location of the file with the configuration info
config.file <- "C:/Diana/Bosch/config.csv" 

# Folder with the data to merge
path <- "C:/Diana/Bosch/Trial"             

# Get basic merged data without any preprocessings in the output file named "MergeAll.xlsx"
result <- simple.merge(path, config.file) 

# Get merged data with recalculated values for other country in the output file named "MergeAll.xlsx"
result <- simple.merge(path, config.file, recalculate = TRUE) 

# Get aggregated by content id merged data in the output file named "MergeAll_aggregated.xlsx"
result <- simple.merge(path, config.file, aggregate = TRUE, create.paid = TRUE, output.file = "MergeAll_aggregated") 

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