How to Make Boxplot in R-Quick Start Guide

[This article was first published on Methods – finnstats, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

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.



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

Timeseries analysis in R » Decomposition, & Forecasting »

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 »

data= ToothGrowth,
main="ToothGrowth ",
        main="Different boxplots for per day growth",
        xlab="Tooth length",

Boxplot in R-ggplot2

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

Decision Trees in R » Classification & Regression »

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.

The post How to Make Boxplot in R-Quick Start Guide appeared first on finnstats.

To leave a comment for the author, please follow the link and comment on their blog: Methods – finnstats. offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)