# How to Make Boxplot in R-Quick Start Guide

Boxplots in R, A boxplot is a plot that displays the five-digit summary of a dataset. The five-digit summary is the lowest value, the first quartile, the median, the third quartile, and the maximum value.

We can use a boxplot to easily visualize a set of data.

Principal component analysis (PCA) in R »

## Boxplots in R

Let’s create a data frame for box plot generation.

data <- data.frame( A = rpois(900, 3), B = rnorm(900), C = runif(900)

Suppose if want to create a single boxplot then the following syntax will be useful.

boxplot(data)

**Output:-**

Let’s take ToothGrowth data frame for Box plot generation.

Timeseries analysis in R » Decomposition, & Forecasting »

head(ToothGrowth)

len supp dose 1 4.2 VC 0.5 2 11.5 VC 0.5 3 7.3 VC 0.5 4 5.8 VC 0.5 5 6.4 VC 0.5 6 10.0 VC 0.5

Suppose if we want to generate one boxplot for each supp in the dataset. Create a boxplot that displays **len** distribution for each supp in the dataset.

LSTM Network in R » Recurrent Neural network »

boxplot(len~supp, data= ToothGrowth, main="ToothGrowth ", xlab="supp", ylab="len", col="red",border="black" )

boxplot(len~dose, data=ToothGrowth, main="Different boxplots for per day growth", xlab="Tooth length", col="green", border="brown", horizontal=TRUE )

## Boxplot in R-ggplot2

We can make use of ggplot2 for boxplot creation. Let’s load the library.

Decision Trees in R » Classification & Regression »

library(ggplot2)

ggplot(data = ToothGrowth, aes(x=as.character(supp), y=len)) + geom_boxplot(fill="orange") + labs(title=" ToothGrowth ", x="Supp", y="len")

Preparing for Kerala PSC check your score now.