quantile() function in
R Language is used to create sample quantiles within a data set with probability[0, 1]. Such as first quantile is at 0.25[25%], second is at 0.50[50%], and third is at 0.75[75%].
Syntax: quantile(x)
Parameters:
x: Data set
Example 1:
Python3 1==
# R program to create
# quantiles of a data set
# Create a data frame
d <- data.frame( name = c("Abhi", "Bhavesh", "Chaman", "Dimri"),
age = c(7, 5, 9, 16),
ht = c(46, NA, NA, 69),
school = c("yes", "yes", "no", "no") )
# Calling quantile() Function
quantile(d$age)
Output:
0% 25% 50% 75% 100%
5.00 6.50 8.00 10.75 16.00
Example 2:
Python3 1==
# R program to create
# quantiles of a data set
# Calling pre-defined data set
BOD
# Calling quantile() Function
quantile(BOD$demand)
quantile(BOD$Time)
Output:
Time demand
1 1 8.3
2 2 10.3
3 3 19.0
4 4 16.0
5 5 15.6
6 7 19.8
0% 25% 50% 75% 100%
8.300 11.625 15.800 18.250 19.800
0% 25% 50% 75% 100%
1.00 2.25 3.50 4.75 7.00