Visualize univariate and bivariate distributions

TODO

  • link to diagCategorical, diagScatter, diagMultivariate, diagAddElements, diagBounding

Install required packages

car, hexbin, beeswarm

Histograms

Histogram with absolute class frequencies

plot of chunk rerDiagDistributions01
plot of chunk rerDiagDistributions01

Add individual values and normal probability density function

plot of chunk rerDiagDistributions02
plot of chunk rerDiagDistributions02

Add estimated probability density function

plot of chunk rerDiagDistributions03
plot of chunk rerDiagDistributions03

To compare the histograms from two groups, see histbackback() from package Hmisc.

Stem and leaf plot


  The decimal point is 1 digit(s) to the right of the |

  15 | 669
  16 | 134
  16 | 5566777789
  17 | 0011112222233333334444444
  17 | 5555566666677777788888888999
  18 | 0000000001111233334444
  18 | 55667779
  19 | 2

Boxplot

plot of chunk rerDiagDistributions04
plot of chunk rerDiagDistributions04
plot of chunk rerDiagDistributions05
plot of chunk rerDiagDistributions05

Dotchart

plot of chunk rerDiagDistributions06
plot of chunk rerDiagDistributions06

Stripchart

plot of chunk rerDiagDistributions07
plot of chunk rerDiagDistributions07
plot of chunk rerDiagDistributions07
plot of chunk rerDiagDistributions07

QQ-plot

plot of chunk rerDiagDistributions08
plot of chunk rerDiagDistributions08
plot of chunk rerDiagDistributions09
plot of chunk rerDiagDistributions09

Empirical cumulative distribution function

plot of chunk rerDiagDistributions10
plot of chunk rerDiagDistributions10

Joint distribution of two variables in separate groups

Simulate data

Identify group membership by plot symbol and color

plot of chunk rerDiagDistributions11
plot of chunk rerDiagDistributions11

Add distribution ellipse

Pooled groups

plot of chunk rerDiagDistributions12
plot of chunk rerDiagDistributions12

Joint distribution of two variables with many observations

Using transparency

plot of chunk rerDiagDistributions13
plot of chunk rerDiagDistributions13

Smooth scatter plot

Based on a 2-D kernel density estimate

plot of chunk rerDiagDistributions14
plot of chunk rerDiagDistributions14

Hexagonal 2-D binning

plot of chunk rerDiagDistributions15
plot of chunk rerDiagDistributions15
'hexbin' object from call: hexbin(x = xx, y = yy, xbins = 20) 
n = 5000  points in nc = 213  hexagon cells in grid dimensions  26 by 21 
      cell           count             xcm              ycm        
 Min.   :  9.0   Min.   :  1.00   Min.   : 44.83   Min.   :-5.868  
 1st Qu.:157.0   1st Qu.:  2.00   1st Qu.: 81.12   1st Qu.:23.699  
 Median :241.0   Median :  8.00   Median :101.32   Median :40.057  
 Mean   :242.4   Mean   : 23.47   Mean   :101.14   Mean   :40.226  
 3rd Qu.:325.0   3rd Qu.: 31.00   3rd Qu.:120.87   3rd Qu.:56.396  
 Max.   :499.0   Max.   :134.00   Max.   :157.78   Max.   :90.498  

Detach (automatically) loaded packages (if possible)

Get the article source from GitHub

R markdown - markdown - R code - all posts