What is the IQR() function in R?
Overview
In R, the IQR() function is used to compute the interquartile range of a given object of numerical values.
The interquartile range of these values is a range where 25% on either side is cut off. Statistically, the interquartile range is the difference between the upper quartile and the lower quartile.
Syntax
IQR(x, na.rm = FALSE, type = 7)
Parameters
This function takes the following parameter values:
x: This represents the numeric vector. This is a required parameter.na.rm: This takes a logical value,TRUEorFALSE, indicating whether missing values be removed or not.type: This represents an integer selecting one of the many quantile algorithms. This is an oprional parameter.
Return value
This method returns the interquartile range of a given object of numerical values.
Example
# creating a numerical objectx <- c(0:10)# implementing the IQR() functionIQR(x)
Explanation
Line 2: We create an R object,
x, containing numerical values from0to10.Line 5: We implement the
IQR()function to determine the interquartile range of the set of numbers and print the result to the console.