my R package for plotting
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
R
examples
man
.Rhistory
DESCRIPTION
NAMESPACE
README.md
redingPlot.Rproj

README.md

redingPlot

redingPlot contains some useful plotting functions. Most of the functions aren't as flexible as your plain vanilla base R plotting functions (e.g. many of the functions only accept the data as a list), but you'll find some better ways to plot things not easily implemented in R. The focus is on plotting the relationships between quantitative and categorical variables while showing the data.


what's here

###why you should install redingPlot

Because the go-to solutions for plotting quantitative x categorical data are insuffient and obfuscating. Bar plots and (to a lesser extent) boxplots present summaries of the data. By presenting a summary instead of the thing we're really interested in (the data), information is thrown away and the reader's ability to assess the conclusions you draw from your data is made impossible. Are there outliers? Are the data roughly normally distributed? How variable are the data? What is the sample size? All these are fundamental questions readers should be able to answer after reading a your graphic, and yet using standard plotting approaches usually doesn't get us close. This is why you use redingPlot.

###how to install redingPlot

Copy and paste everything that looks like this into R

  • if (!"devtools" %in% installed.packages()) install.packages("devtools"); library(devtools)
  • install_github("lukereding/redingPlot")
  • restart R--you only have to do this when you first install redingPlot
  • load redingPlot as you would any other package: library(redingPlot)
  • try ?scatter and make sure the help file loads currently, and maybe try one of the examples: scatter(trees[,1],trees[,2],xlab="tree girth (in.)",ylab="tree height (ft.)",main="scatter() example"). If it looks good, you're all set!

###available functions:

To find the code to generate these plots and other examples, check the help files (i.e. ?bar).

  • violinplot() -- boxplot + 1/2 of a violinplot + data jittered
    violinplot!
  • violinplot2() -- boxplot + violinplot on top + data jittered
    violinplot2!
  • cats_meow() -- barplot + mean with 95% confidence interval + data jittered
    meow!
  • bar() -- barplot with data jittered on top
    bar
  • beeStrip() -- plot the data for each group as a histogram, draw line at the mean for each group
    beeStrip
  • beeStripBox() -- same as beeStrip, but plot a boxplot alongside each histogram
    beeStripBox
  • simple() -- plots the mean for each group as a line along the individual data points jittered
    simple
  • strip() -- plots the mean for each group as a point with along the individual data points jittered
    strip
  • scatter() -- provides good defaults for a scatterplot. Also automatically performs a linear regression and prints relevant stats to the plot
    scatter
  • scatter_hist() -- scatter with marginal histograms.
    scatter_hist
  • paired() -- boxplot + paired data connected with points. only for use with two groups
    paired

####these plots are designed with the following philosophy in mind:

  • every part of the graph should have a clear purpose
  • show the data, some summary of the data or parameter estimate of interest, and some measure of variability about that estimate
  • clearly label sample sizes
  • state some measure of effect size
  • state the the test used to assess statistical significance and the resulting p-value
  • don't extrapolate
  • use color thoughtfully. Or just use viridis. Why? (a) It's perceptually uniform. (b) It looks good. (c) It works just as well printed in black and white. (d) It's accessible to people with the most common forms of colorblindness. (e) It works for representing categories or for representing a quantitative variable. (f) You'll never need to justify your color scheme ever again. Note that this is also true of the other colormaps provided in the viridis package (plasma, magma, and inferno), but they don't look as nice.

Some of these things are not implemented (yet) in the graphics in the package.


Your graphics should not stop here. Good graphics should tell the whole story without requiring the reader to dive into the figure caption. We put axis labels on our graphs so that our readers don't have to sift through text to make connections and extract meaning. Most graphics are easily improved by reminding the reader what they're looking at. The graphs produced by these plotting functions should provide a template for further tweaking either within R (for greater reproducibility when your advisor or a reviewer demands a change) or within a graphics editor like Inkscape.