To calculate five number summary in R, you can use fivenum() function. This function gives minimum, maximum, median, 1st quartile and 3rd quartile value of dataset.

The following method shows how you can do it with syntax.

Method: Use fivenum() Function

fivenum(data)

The following example shows how to use fivenum() function in R.

Use fivenum() to Calculate Five Number Summary

Let’s see how we can calculate five number summary of data frame:

# Create data frame
df <- data.frame(Machine_name=c("A","B","C","D","E","F","G","H"),
                 Pressure=c(78.2, 78.2, 71.7, 80.21, 80.21, 82.56, 72.12, 73.85),
                 Temperature=c(35, 36, 36, 38, 32, 32, 31, 34))

# Calculate five number summary of data frame
d <- fivenum(df$Temperature)

# Print five number summary of data frame
print(d)

Output:

[1] 31.0 32.0 34.5 36.0 38.0

The output shows minimum value is 31.0, Q1 is 32.0, the median is 34.5, Q3 is 36.0, and the maximum value is 38.0.