1. Learn
  2. /
  3. Courses
  4. /
  5. Basic Statistics

Exercise

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.

Instructions

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