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.
IQR(x, na.rm = FALSE, type = 7)
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, TRUE
or FALSE
, 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.
This method returns the interquartile range of a given object of numerical values.
# creating a numerical objectx <- c(0:10)# implementing the IQR() functionIQR(x)
Line 2: We create an R object, x
, containing numerical values from 0
to 10
.
Line 5: We implement the IQR()
function to determine the interquartile range of the set of numbers and print the result to the console.