Get startedGet started for free

IQR and boxplot

To better visualise your data's quartiles you can create a boxplot using the function boxplot() (in the same way as you used hist() and barplot()). Similarly, you can calculate the interquartile range manually by subtracting the value of the third quartile from the value of the first quartile, or we can use the function IQR() on your variable of interest. Let's try out making a boxplot and calculating the interquartile range of the mtcars variable qsec.

This exercise is part of the course

Basic Statistics

View Course

Exercise instructions

  • Use the boxplot() function on the variable qsec of mtcars
  • Calculate the interquartile range of qsec from mtcars using IQR()

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Make a boxplot of qsec

# Calculate the interquartile range of qsec
Edit and Run Code