CommencerCommencer gratuitement

Box and whisker plot

A box and whisker plot gives information regarding the shape, variability, and center (or median) of a data set. It is particularly useful for displaying skewed data.

By comparing the data set to a standard normal distribution, you can identify departure from normality (asymmetry, skewness, etc). The lines extending parallel from the boxes are known as whiskers, which are used to indicate variability outside the upper and lower quartiles, i.e. outliers. Those outliers are usually plotted as individual dots that are in-line with whiskers.

In the video, you also saw how to use boxplot() to create a horizontal box and whisker plot:

> boxplot(amazon_stocks,
          horizontal = TRUE,
          main = "Amazon return distribution")

In this exercise, you will draw a box and whisker plot for Apple stock returns in rtn, which is in your workspace.

Cet exercice fait partie du cours

Visualizing Time Series Data in R

Afficher le cours

Instructions

  • Draw a box and whisker plot of the data in rtn
  • Draw a box and whisker plot for a standard normal distribution with 1000 points, which you can create with rnorm(1000)
  • Redraw both plots, in their original order, on the same 2x1 graphical window and make them horizontal

Exercice interactif pratique

Essayez cet exercice en complétant cet exemple de code.

# Draw box and whisker plot for the Apple returns


# Draw a box and whisker plot of a normal distribution


# Redraw both plots on the same graphical window


Modifier et exécuter le code