How do I get just the first quartile from a column
Asked Answered
E

2

17

I have a dataframes with a column called Means. I want to get just the first quartile from this column. I know I can use quartile (df) or summary (df) but this gives me all the quartiles. How do I get just the first?

Environs answered 1/9, 2015 at 10:30 Comment(1)
See function quantile and its probs argument.Tilley
E
35

You could try this:

#sample data
Means <- runif(100)

#and this is how you get the first quartile
> summary(Means)[2]
1st Qu. 
 0.2325 

Or using function quantile as per Pascal's comment:

> quantile(Means, 0.25)
      25% 
0.2324663 
Endothelium answered 1/9, 2015 at 10:46 Comment(1)
Note that you can always use a character reference as well: summary(Means)[["1st Qu."]].Costanzo
A
0

To get just the value of the first quartile, you can do this:

> quantile(Means)[["25%"]]
[1] 0.2209037
Aconcagua answered 19/12, 2023 at 14:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.