The gf_boxplot() function will generate a boxplot (also known as a box and whiskers plot).
A boxplot splits the data into quartiles, where each whisker and each half of the box contains 25% of all the observations. They are helpful for visualizing the five-number summary (minimum, Q1, Q2/median, Q3, maximum) for a single quantitative variable. Outliers appear as points beyond the whiskers.
Boxplots can also be split into the groups of a categorical variable, and they can also be chained onto other plots (e.g., histograms and jitter plots).
Example 1:
# Boxplot of Wt in MindsetMatters
gf_boxplot( Wt ~ 1 , data = MindsetMatters )
Example of output from running the code above:
Example 2:
# Boxplot of Thumb by Height3Group in Fingers
gf_boxplot( Thumb ~ Height3Group , data = Fingers )
Example of output from running the code above:
Example 3:
# Boxplot and histogram of Thumb in Fingers
gf_histogram(~ Thumb, data = Fingers) %>%
gf_boxplot( -1 ~ Thumb)
Example of output from running the code above:
Related Articles
gf_jitter()
The gf_jitter() function will generate a jitter plot. A jitter plot is a point plot (similar to a scatter plot, such as gf_point()) but the points are moved slightly ("jittered") so that they do not overlap as much. This can help make it easier to ...
gf_lm()
The gf_lm() function overlays the best-fitting regression line on a scatter plot when chained onto gf_point(). Example: # adds a regression line gf_point(Thumb ~ Height, data = Fingers) %>% gf_lm( color = "orange", size = 2 )
gf_bar()
The gf_bar() function creates a bar graph. It can be used to visualize the distribution of a categorical variable by counting the number of observations for each group of the category. Bar graphs can also be used with the gf_facet_grid() function. ...
gf_density()
The gf_density() function will overlay a density plot onto a density histogram (i.e., gf_dhistogram(), not gf_histogram()). The density plot is a smoothed out version of the distribution. They can be helpful when you want to get a better idea of the ...
gf_histogram()
The gf_histogram() function will create a frequency histogram for a quantitative variable. This means it will show the number of cases observed in the data for each value of the variable. (See gf_dhistogram() for information on density histograms). ...