Creating a DataFrame
Here we can use any in-built datasets in R (the list of datasets can be viewed using data( ) command) or even create one. Let’s create a data frame and visualize it.
R
# Creating a data frame # variables for columns game = rep ( c ( 'Footsal' , 'Slamdunk' , 'VolleyBall' ), each=50) level = rep ( c ( 'low' , 'high' ), each=25) score = runif (150, min=1, max=500) year = rep ( c (1992,1993,1994),each=50) data = data.frame (game, level, score,year) head (data) |
Output:
How to Make Grouped Boxplot with Jittered Data Points in ggplot2 in R
In this article, we will see how to make use of ggplot2 package in R Programming Language to plot grouped boxplots with jittered data points.
Grouped Boxplots help us visualize two or more features/variables in a single plot using the grouping variable in ggplot2. The jittered points are data points that belong to another variable and are plotted on top of the grouped boxplot for a better comparison of the spread of data points of the considered variables.