In the last exercise, we calculated the IQR by finding the quartiles using R and finding the difference ourselves. The stats library has a function that can calculate the IQR all in one step.

The IQR() function takes a dataset as a parameter and returns the Interquartile Range.

dataset = c(4, 10, 38, 85, 193) interquartile_range = IQR(dataset)



Let’s calculate the IQR again, but this time, use the stats function.

Create a variable named interquartile_range and set it equal to the result of calling IQR() using songs as an argument.

Take this course for free

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?