Question: How to make boxplots in ggpubr?"

A boxplot is a graph that gives you a good indication of how the values in the data are spread out. Boxplots are a standardized way of displaying the distribution of data based on a five number summary (the minimum, the first quartile, the median, the third quartile, and the maximum).

We’ll use the “palmerpenguins” package for this example.

Data Preparation

library(palmerpenguins)
data(penguins)

Plot Boxplot

Using the function boxplot() from base R, we can create our plot from the data we previously loaded in. Using the $ function, we can select a specific column that we want to use in this plot. The argument “ylab” allows us to name the respective y-axis, and “col” changes the color of the plot.

boxplot(penguins$bill_length_mm,
        ylab = "Bill Length (mm)",
        col = 3)

Transversley, using the same boxplot() function, we can select different cateogries using $ to create the plot. The argument “xlab” allows us to name the respective x-axis, with the inclusion of“horizontal = TRUE” argument.

boxplot(x = penguins$bill_depth_mm,
        xlab = "Bill depth (mm)",
        horizontal = TRUE,
        col = 3)

Additional Reading

https://www.datamentor.io/r-programming/box-plot/

Keywords

  1. boxplot
  2. quartile
  3. ranges
  4. maximum
  5. minimum
  6. median
  7. boxplot()
  8. xlab
  9. ylab