Our Standard Libraries

As a team of coders — it’s very healthy and good practice to use the same set of libraries. This improves our ability to collaborate and the readability of our code.

This document showcases the libraries that we picked out as a team, and should always be used over their alternatives if the same results can be achieved. Find the CRAN link by clicking the package name. If you need examples, look for the vignettes or install the package and use the function browseVignettes("package_name")

Preferred / go-to packages

We first try to solve most of our analytical problems with the packages below. This is not an exhaustive list, so there will be cases where we’ll need additional or different packages – which is fine, as long as it is necessary. Also have a look at the noteworthy packages section where you might find what it is you are looking for.

Category

Package

What it does

Discussion

Reading / Writing Data

readr

Reads and writes Comma Seperated Values (.csv)

We are avid fans of the tidyverse and will thus be using readr over data_table. Only if absolutely necessary, we can use data_table for the added speed.

Reading / Writing Data

haven

Reads and writes S, SAS, SPSS and Stata files

Again, a tidyverse classic which has our preffered piping system.

Reading / Writing Data

readxl

Reads and writes Excel files (.xls,.xlsx)

Again, a tidyverse classic which has our preffered piping system.

Data Manipulation

tidyverse This collection of packages allows us to manipulate data frames, datetime, factors, lists, strings and tidying object outputs This package contains most of our data wrangling needs that work tightly with our reading and writing packages.

Data Manipulation

zoo Working with timeseries. The zoo package is state of the art for time-series objects and will serve it's purpose for most modeling packages.

Data Visualisation

ggplot2 Create extremely customizable plots Easily the most-used package for R and there is no better alternative.
Document generation knitr Report generation & tables Knitr will be our go-to packagewhen we want to create reports and tables. It changed reproducible workflows immensely.
Interactive tables DT Interactive tables DT has a great interactable andcustomizable interface for HTML generated tables which we can include in any online application that we create. Also incorperated into Shiny
Interactive Data Vizualisations echarts4r Interactive plots Includes a sophisticated API
Modeling | Clustering clValid

Run & compare multiple clustering techniques

This package runs and compares multiple clustering techniques such as kmeans, diana, agnes, hierarchical and more.
Modeling | Classification randomForest

Classification based on a forest of trees using random inputs

Modeling | Regressions caret The caret package (short for _C_lassification _A_nd _RE_gression _T_raining) is a set of functions that attempt to streamline the process for creating predictive models.
Feature Selection Boruta Tree based features selection that uses shadow of original variables An all relevant feature selection wrapper algorithm. It finds relevant features by comparing original attributes' importance with importance achievable at random, estimated using their permuted copies (shadows).
Package/Project documentation roxygen2 Generate your Rd documentation, 'NAMESPACE' file, and collation field using specially formatted comments. Writing documentation in-line with code makes it easier to keep your documentation upto-date as your requirements change

Other noteworthy packages

Category

Package

What does it do?

Extensive description

Reading / Writing Java/Debian Data

foreign

Also reads formats like DBF, WEKA and others.

Reading and writing data stored by some versions of 'Epi Info', 'Minitab', 'S', 'SAS', 'SPSS', 'Stata', 'Systat', 'Weka', and for reading and writing some 'dBase' files.

Reading / Writing ML Data

XML

Reads and writes XML files

Many approaches for both reading and creating XML (and HTML) documents (including DTDs),both local and accessible via HTTP or FTP. Also offers access to an 'XPath' interpreter.

Reading / Writing JSON Data

jsonlite

Reads and writes JSON files

A fast JSON parser and generator optimized for statistical data and the web. Started outas a fork of 'RJSONIO', but has been completely rewritten in recent versions. The package offers flexible, robust, high performance tools for workingwith JSON in R and is particularly powerful for building pipelines and interacting with a web API.
Working with APIs httr Interacting / obtaining data from API's Useful tools for working with HTTP organised by HTTP verbs (GET(), POST(), etc). Configuration functions make it easy to control additional request components (authenticate(), add_headers() and so on).
Webscraping rvest Read data from the web

Web scraping: Extract data from HTML pages. Inspired by Python's Beautiful Soup. Works well with Selectorgadget.

Data Visualisation

widgetframe Writes interactive HTML widgets for easy embadding on wordpress This package allows for easier embedding of 'htmlwidgets' in content management systems such as 'wordpress', 'blogger' etc.

Data Visualisation

flexdashboard Creating HTML Dashboards

If Shiny is too complex and involved for your needs, this package offers asimpler (if somewhat less robust) solution based on R Markdown.

Modeling | Classification | Regression with SVM

e1071 Package for classification & regression Functions for latent class analysis, short time Fourier transform, fuzzy clustering, support vector machines, shortest path computation, bagged clustering, naive Bayes classifier.

Modeling | Classification | Regression with Trees

rpart Package for classification & regression

Recursive partitioning for classification, regression and survival trees. An implementation of most of the functionality of the 1984 book by Breiman, Friedman, Olshen and Stone.

Data Visualisation

tables Formula-based tables construction

Data Visualisation

stargazer Pretty regression outputs Produces LaTeX code, HTML/CSS codeand ASCII text for well-formatted tables that hold regression analysis results from several models side-by-side, as well as summary statistics.

Modeling | Classification | Regression with regularization

glmnet LASSO and Ridge Regression Extremely efficient procedures for fitting the entire lasso or elastic-netregularization path for linear regression, logistic and multinomial regression models, Poisson regression and the Cox model

Modeling | Classification | Regression

lme4 Hierarchical models Fit linear and generalized linear mixed-effects models. The models and their components are represented using S4 classes and methods.

Modeling | Classification | Regression with Bayesian approach

brms Interface to STANfor highly sophisticated regressions Fit Bayesian generalized (non-)linear multivariate multilevel models using 'Stan' for full Bayesian inference. A wide range of distributions and link functions are supported, allowing users to fit -- among others -- linear, robust linear, count data, survival, response times, ordinal, zero-inflated, hurdle, and even self-defined mixture models all in a multilevel context.

Parallel computing

foreach A better for loop that allows for error handling, parallelization, etc. Support for the foreach looping construct. Foreach is an idiom that allows for iterating over elements in a collection, without the use of an explicit loop counter. This package in particular is intended to be used for its return value, rather than for its side effects. In that sense, it is similar to the standard lapply function, but doesn't require the evaluation of a function. Using foreach without sideeffects also facilitates executing the loop in parallel.
Modeling | Forecasting prophet Library from Facebook for univariate time series forecasting Implements a procedure for forecasting time series data based on an additive model where non-linear trends are fit with yearly, weekly, and daily seasonality, plus holiday effects. It works best with time series that have strong seasonal effects and several seasons of historical data. Prophet is robust to missing data and shifts in the trend, and typically handles outliers well.

Modeling | Classification | Regression

vars vector autoregression models

Estimation, lag selection, diagnostic testing, forecasting, causality analysis, forecast error variance decomposition and impulse response functions of VAR models and estimation of SVAR and SVEC models.

Modeling | Classification | Regression with neural networks

keras Package to create arbitrarily complex neural networks Interface to Keras, a high-level neural networks 'API'. 'Keras' was developed with a focus on enabling fast experimentation, supports both convolution based networks and recurrent networks (as well as combinations of the two), and runs seamlessly onboth 'CPU' and 'GPU' devices.

Tables Presentation

kableExtra styling of kable tables in rmarkdown

Build complex HTML or 'LaTeX' tables using 'kable()' from 'knitr' and the piping syntax from 'magrittr'. Function 'kable()' is a light weight table generator coming from 'knitr'. This package simplifies the way to manipulate the HTML or 'LaTeX' codes generated by 'kable()' and allows users to construct complex tables and customize styles using a readable syntax.

Modeling | Classification | Regression

bnlearn Package to learn causal structuresand estimate parameters of bayesian networks

Bayesian network structure learning, parameter learning and inference. This package implements constraint-based (PC, GS, IAMB, Inter-IAMB, Fast-IAMB, MMPC, Hiton-PC), pairwise (ARACNE and Chow-Liu), score-based (Hill-Climbing and Tabu Search) and hybrid (MMHCand RSMAX2) structure learning algorithms for discrete, Gaussian and conditional Gaussian networks, along with many score functions and conditional independence tests

Modeling | Classification | Regression

BTYDplus Package to estimate BTYD models on transactional data

Provides advanced statistical methods to describe and predict customers' purchase behavior in a non-contractual setting. It uses historic transaction records to fit a probabilistic model, which then allows to compute quantities of managerial interest on a cohort- as well as on a customer level (Customer Lifetime Value, Customer Equity, P(alive), etc.).

Data Visualisation

ggplot extentions

Egg, ggrepel, ggthemes,

Egg: align multiple plots

ggrepel: add repel labels

ggthemes: more geoms/themes

Interactive applications Makes it incredibly easy to build interactive web applications with R. Automatic "reactive" binding between inputs and outputs and extensive prebuiltwidgets make it possible to build beautiful, responsive, and powerful applications with minimal effort.