- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to find the first quartile for a data frame column in R?
The first quartile is the value that exists at the 25th percentile, that means there are 25% of values in the data that lie below first quartile. When we find the summary of data frame the output returns this value but if we want to extract only the first quartile then quantile function can be used by specifying the percentage using 0.25.
Consider the below data frame −
Example
x<-rnorm(20) df1<-data.frame(x) df1
Output
x 1 -2.0468677 2 1.6699889 3 0.6812778 4 -1.2456486 5 0.9066429 6 0.4191929 7 1.0230824 8 -1.5463724 9 1.0890182 10 -1.7451677 11 0.3218517 12 -0.2812037 13 0.2178108 14 0.4074959 15 -1.9794296 16 0.2920860 17 0.9381717 18 -0.3378574 19 -1.1992889 20 -0.4656026
Finding the first quartile of x −
quantile(df1$x,0.25)
25% -1.210879
Example
y<-rpois(20,5) df2<-data.frame(y) df2
Output
y 1 7 2 6 3 3 4 4 5 2 6 8 7 6 8 5 9 3 10 1 11 6 12 1 13 3 14 5 15 9 16 3 17 6 18 3 19 4 20 5
Finding the first quartile of y −
quantile(df2$y,0.25)
25% 3
Example
z<-rexp(20,3.2) df3<-data.frame(z) df3
Output
z 1 0.447126145 2 0.349641120 3 1.013647257 4 1.074568795 5 0.351561016 6 0.253472100 7 0.083377626 8 0.432579828 9 0.244444691 10 0.003626295 11 0.396824568 12 0.392368738 13 0.233784862 14 0.103773163 15 0.176434586 16 0.177519043 17 0.016000915 18 0.290995177 19 0.031436406 20 0.389733464
Finding the first quartile of z −
quantile(df3$z,0.25)
25% 0.1582692
- Related Articles
- Create a quartile column for each value in an R data frame column.
- How to find mode for an R data frame column?
- How to find the trimmed mean for a column of an R data frame?
- How to find the column mean of first n number of rows in R data frame?
- How to convert first letter into capital in R data frame column?
- How to remove first character from column name in R data frame?
- How to find the inverse of log10 for an R data frame column?
- How to extract the first digit from a character column in an R data frame?
- How to extract the first highest occurring value in an R data frame column?
- How to find the average of a particular column in R data frame?
- How to match a column in a data frame with a column in another data frame in R?
- How to find the sum of squared deviations for an R data frame column?
- How to find mathematical set using a data frame column in R?
- How to move a column from other position to first position in an R data frame?
- How to find the unique values in a column of an R data frame?

Advertisements