Boxplots are a measure of how well data is distributed across a data set. This divides the data set into three quartiles. This graph represents the minimum, maximum, average, first quartile, and the third quartile in the data set. Boxplot is also useful in comparing the distribution of data in a data set by drawing a boxplot for each of them.
R provides a boxplot() function to create a boxplot. There is the following syntax of boxplot() function:
Let?s see an example to understand how we can create a boxplot in R. In the below example, we will use the "mtcars" dataset present in the R environment. We will use its two columns only, i.e., "mpg" and "cyl". The below example will create a boxplot graph for the relation between mpg and cyl, i.e., miles per gallon and number of cylinders, respectively.
Boxplot using notch
In R, we can draw a boxplot using a notch. It helps us to find out how the medians of different data groups match with each other. Let's see an example to understand how a boxplot graph is created using notch for each of the groups.
In our below example, we will use the same dataset ?mtcars."
R provides an additional plotting scheme which is created with the combination of a boxplot and a kernel density plot. The violin plots are created with the help of vioplot() function present in the vioplot package.
Let's see an example to understand the creation of the violin plot.
Bagplot- 2-Dimensional Boxplot Extension
The bagplot(x, y) function in the aplpack package provides a biennial version of the univariate boxplot. The bag contains 50% of all points. The bivariate median is approximate. The fence separates itself from the outside points, and the outlays are displayed.
Let?s see an example to understand how we can create a two-dimensional boxplot extension in R.