17.1 Introduction

  • In the 1st few sections we explored several graphing approachs (plot, ggpubr, ggplot::qplot, ggplot)
  • Now we will focus on the ggpubr extension of ggplot
  • We’ll use ggpubr::ggboxplot to graphically explore our data

17.1.1 Goals & objectives

Create plots to explore variation in the frogarms data, with an emphasis on boxplots using ggpubr::ggboxplot().

17.1.2 Packages

  • ggplot2
  • cowplot
  • ggpubr
  • dplyr

17.1.3 Outline

  • load packages if necessary
  • load data and subset data if necessary
  • make data exploration graphs
  • boxplots, hinged boxplots, boxplots with raw data

17.1.4 Vocab

  • jittering
  • boxplot
  • R object
  • categorical variable
  • continuous variable
  • faceting

17.1.5 Preliminaries

17.1.5.1 Load packages

If not already loaded, we need the wildlifeR package, which lives on Github

library(devtools)
install_github("brouwern/wildlifeR")

library(wildlifeR)

We also need several other packages for visualization. We’ll use the ggplot2 package for plotting, and the cowplot package for some nice plotting defaults. cowplot also has a hand function for putting two plots into the same graph.

library(ggplot2)
library(cowplot)
library(ggpubr)
library(dplyr)

17.1.5.2 Load data

Load the frogarms data by Buzatto et al (2015) if its not already loaded.

data(frogarms)

17.1.5.3 Subset your data

The function make_my_data2L() will extract out a random subset of the data. Change “my.code” to your school email address, minus the “@ pitt.edu” or whatever your affiliation is. This does not need to be done if you did this as part of the previous lesson

my.frogs <- make_my_data2L(dat = frogarms, 
                           my.code = "nlb24", # <=  change this!
                           cat.var = "sex",
                           n.sample = 20, 
                           with.rep = FALSE)