In this series of 3 posts, I use a simulated dataset (7 variables -3 factor and 4 numeric - and a sample size of 50) to create graphs/charts using base R, and replicate them using ggplot2, and rCharts. This is not an attempt to create an exhaustive database of graphs/charts of all possible combinations, but it was an exercise to generate some of the common ones (in my view). These include dot plots, histograms, box plots, bar charts, scatter plots, density curves, and line graphs and a few more. I am sure the code can be further optimized and it could use some finishing touches with many things like legends, axes labels, and color, but at the core, I think it does its job. Thanks to Ramnath Vaidyanathan for having answers to all questions and to the kind rCharts, ggplot2, and R community for the free knowledge base available on the Internet. The code for these pages can be found on github.

Part 1 in the series (using Base R) can be found here

Part 2 in the series (using ggplot2) can be found here

# Data

Let us begin by simulating our sample data of 3 factor variables and 4 numeric variables.

# Initialize the libraries used for this page

# One Variable: Numeric Variable

## Index Plot using HighChart

## Histogram using PolyChart

## Density plot using NVD3

## Boxplot using HighChart

## One Variable: Factor Variable

## Bar plot using NVD3

## Pie Chart using NVD3

## Two Variables: Two Numeric Variables

## Index plots- line plots with observation number x-axis - Using HighCharts

## Density plots for NumVar1 & NumVar2 using NVD3

## Scatter Chart using NVD3 - NumVar1 (x-Axis) versus NumVar2 (y-Axis)

# Two Variables: Two Factor Variables

## Mosaic plot/horizontal marimekko using Dimple

## Bar chart using UV Chart

## Stacked Bar chart using UV Chart

## 100% Stacked Bar chart using UV Chart

## Two Variables: One Factor and One Numeric

## Box plots of numeric var over the levels of the factor var using HighCharts

## Density plot numeric var across multiple levels of the factor var - NVD3

## Mean of one numeric var over levels of one factor var - Scatter Chart- HighCharts

## Mean of one numeric var over levels of one factor var - Bar Chart - HighCharts

# Three Variables: Three Factor Variables

## Bar Chart - PolyCharts

## Three Variables: One Numeric and Two Factor Variables

## Boxplot of NumVar1 over an interaction of 6 levels of the combination of FacVar1 and FacVar2 - PolyCharts

## Dot chart Equivalent - Mean of 1 Numeric variable over levels of two factor vars - PolyCharts

## Interaction Plot - Line Chart equivalent - HighCharts

## Bar chart - Mean of 1 Numeric variable over levels of two factor vars - HighCharts

# Three Variables: Two Numeric and One Factor Variables

## Scatter Plot with color/shape identifying the factor variable - HighCharts

# Three Variables: Three Numeric Variables

## Line Chart - one of three vars is along the x-axis - NVD3

## Stacked and 100% Stacked Area Chart - one of three vars is along the x-axis - NVD3

## Bubble plot - scatter plot of NumVar1 and NumVar2 with individual observations sized by NumVar3 - HighCharts

## Scatterplot Matrix of all Numeric Vars, colored by a Factor variable

Do not know if this is possible using rChartsâ€¦ but what is possible is the ability to see the scatterplots of any two sets of numeric vars colored by any factor var - Used NVD3

# References

The rCharts page and gallery at: http://rcharts.io/ and the github page at: https://github.com/ramnathv/rCharts