Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

r get value only from quantile() function

Tags:

r

quantile

I'm sorry for what may be a silly question. When I do:

> quantile(df$column, .75) #get 3rd quartile 

I get something like

75%  1234.5  

Is there a way to just get the value (1234.5) without the descriptive "75%" string? Thank you very much.

like image 244
rstruck Avatar asked Feb 10 '15 21:02

rstruck


People also ask

How do you find the value of quantile?

We often divide the distribution at 99 centiles or percentiles . The median is thus the 50th centile. For the 20th centile of FEV1, i =0.2 times 58 = 11.6, so the quantile is between the 11th and 12th observation, 3.42 and 3.48, and can be estimated by 3.42 + (3.48 - 3.42) times (11.6 - 11) = 3.46.

How does R calculate quantiles by group?

To group data, we use dplyr module. This module contains a function called group_by() in which the column to be grouped by has to be passed. To find quantiles of the grouped data we will call summarize method with quantiles() function.


2 Answers

You can also use unname

> result <- quantile(c(1,2,3,4),0.75) > unname(result) [1] 3.25 

Also you can subset by using [[

> result[[1]] [1] 3.25 
like image 76
Jilber Urbina Avatar answered Oct 08 '22 09:10

Jilber Urbina


Now you can use names = FALSE as argument.

> quantile(c(1,2,3,4),0.75, names = FALSE) [1] 3.25 
like image 30
aldo_tapia Avatar answered Oct 08 '22 10:10

aldo_tapia