## A simple function to install and load packages in R

One function to rule the world, or install or load your packages for you I was starting to despair at the amount of packages I end up using during the task of transforming, cleaning, modelling and validating some of my models. I thought there must be a simple approach to dealing with this? So, I…

## DPLYR: A Beginners Guide

What is DPLYR? Dplyr is a grammar of data manipulation, providing a consistent set of verbs that help you solve the most common data manipulation challenges. The next series of examples will show how you can use the shortcuts in Dplyr to achieve the results of traditional R data manipulation, but faster. Setting dplyr up…

## Violin and density plots in ggplot2

Violin Plots This chart is a combination of a Box Plot and a Density Plo that is rotated and placed on each side, to show the distribution shape of the data. The thick black bar in the centre represents the interquartile range, the thin black line extended from it represents the 95% confidence intervals, and the white dot is the…

## Box Plots in ggplot2

Setting up the plot The box plot, in ggplot2, can be really powerful and useful for analysing variation. I will show a few examples of different types of box plots in ggplot2. Basic Box Plot 1 2 3 4 5 6 7 8 9 10 library(ggplot2) theme_set(theme_classic()) # Plot plot <- ggplot(mpg, aes(class, cty)) plot…

## Histogram with auto binning in ggplot2

Histograms (with auto binning) Again, we will use the mtcars dataset and use the fields in that to produce the chart, as we are doing this there is nothing to do on the data preparation side. That leaves us to have fun with the plot. Building the Histogram with auto binning I set up the…

## Diverging Dot Plot and Lollipop Charts – Plotting Variance with ggplot2

Creating the Dot Plot Variance chart The data preparation was used in the previous blog entitled: Diverging Bar Charts – Plotting Variance with ggplot2. Refer to that if you need to know how to create the data prior to this tutorial. Setting up the Dot Plot Variance chart 1 2 3 4 5 6 7 8…

## Diverging Bar Charts – Plotting Variance with ggplot2

Diverging Bar Charts The aim here is to create a diverging bar chart that shows variance above and below an average line. In this example I will use Z Scores to calculate the variance, in terms of standard deviations, as a diverging bar. This example will use the mtcars stock dataset, as most of the data I…

## Pareto Chart in ggplot2

Background of Pareto Charts A Pareto chart, named after Vilfredo Pareto, is a type of chart that contains both bars and a line graph, where individual values are represented in descending order by bars, and the cumulative total is represented by the line. These charts are highly utilised in Six Sigma circles and conform to the Pareto Principle. The construction…