# How to find the quantiles in R without quantile name?

The calculation of quantiles in R is very simple, we just need to use quantile function and it returns all the quantiles that are 0%, 25%, 50%, 75% and 100%. If we want to avoid the printing the name of these quantiles then we can use names=FALSE with the quantile function. For example, if we have a vector called x then the quantiles without names can be found as quantile(x,names=FALSE).

## Example

Live Demo

x1<-sample(1:100,50,replace=TRUE)
x1

## Output

[1] 44 14 59 92 36 86 95 28 5 9 25 85 5 36 81 50 60 85 86 35 94 58 26 67 65
[26] 58 28 10 74 4 27 75 77 70 81 19 14 21 63 80 69 45 55 76 85 46 35 51 17 18

## Example

quantile(x1)

## Output

0%    25%   50%   75%   100%
4.00 26.25 53.00 75.75 95.00

## Example

quantile(x1,names=FALSE)

## Output

[1] 4.00 26.25 53.00 75.75 95.00

## Example

Live Demo

x2<-sample(1:500,100)
x2

## Output

[1] 336 209 108 328 304 29 337 43 33 320 4 90 24 279 30 16 165 350
[19] 188 434 314 239 270 482 256 255 271 34 406 135 159 222 438 174 333 152
[37] 9 360 424 374 76 349 14 240 298 266 471 61 268 466 122 72 285 151
[55] 5 250 158 341 437 498 71 375 423 177 455 144 28 47 425 383 200 465
[73] 263 372 254 168 388 281 75 420 132 315 485 11 382 448 31 149 86 418
[91] 495 180 184 185 189 39 233 310 447 89

## Example

quantile(x2,names=FALSE)

## Output

[1] 4.0 118.5 252.0 363.0 498.0

## Example

Live Demo

x3<-runif(30,2,5)
x3

## Output

[1] 3.307291 2.975753 3.034199 3.428812 4.961158 4.801980 2.923868 3.200937
[9] 3.693147 2.959462 3.099583 4.732935 4.228120 2.540026 3.270269 2.016999
[17] 4.849105 2.433009 4.075568 3.943937 4.468639 3.200320 3.536432 2.807739
[25] 2.205590 4.335544 3.822639 4.670129 3.523324 4.845408

## Example

quantile(x2,0.50,names=FALSE)

## Output

[1] 252

## Example

quantile(x2,c(0.25,0.50,0.75),names=FALSE)

## Output

[1] 118.5 252.0 363.0

## Example

Live Demo

x4<-rpois(100,6)
x4

## Output

[1] 11 4 5 6 4 7 5 4 4 6 8 3 9 5 6 8 4 8 5 8 6 3 7 4 8
[26] 6 8 8 6 5 11 7 10 5 6 6 8 8 6 7 6 5 5 8 5 6 0 7 4 8
[51] 7 5 4 6 7 8 10 5 11 4 7 5 5 8 9 4 4 7 10 5 6 4 15 3 2
[76] 7 4 4 7 10 5 7 5 8 11 8 4 6 4 5 7 7 6 4 9 11 6 13 2 3

## Example

quantile(x4,names=FALSE)

## Output

[1] 0 5 6 8 15

## Example

Live Demo

x5<-rpois(100,50)
x5

## Output

[1] 58 52 65 48 47 42 52 46 45 41 39 59 44 55 54 45 40 36 55 49 50 46 43 48 46
[26] 42 61 58 50 43 53 47 50 51 43 53 44 52 53 47 52 59 49 51 53 46 54 51 51 70
[51] 44 42 48 54 49 53 50 46 60 46 49 59 53 57 52 38 57 53 44 51 52 70 42 49 46
[76] 39 63 56 46 46 51 36 49 52 59 47 46 48 54 46 46 52 47 55 48 41 42 42 39 49

## Example

quantile(x5,names=FALSE)

## Output

[1] 36 46 49 53 70

## Example

Live Demo

x6<-rexp(50)
x6

## Output

[1] 1.67371919 1.44920661 0.94011063 2.52527092 0.38956936 0.20798087
[7] 0.51312287 1.27945249 1.02433258 2.64801398 0.08305410 1.40810994
[13] 2.19267032 0.13633922 1.37629201 1.36587000 0.50256418 2.80460185
[19] 0.19555703 1.01200693 1.25900192 0.12961335 1.62051718 3.56861318
[25] 2.28511612 0.23772985 1.65338082 2.33044506 0.52189922 0.27737473
[31] 3.00384187 1.32312869 0.47135586 0.89140482 0.76859047 0.46382017
[37] 1.14693919 1.25443125 0.83317864 0.21678377 1.46683187 1.59128467
[43] 0.06808994 1.04027179 0.73648633 0.49386045 0.46888087 0.40550070
[49] 0.28640033 0.24462415

## Example

quantile(x6,names=FALSE)

## Output

[1] 0.06808994 0.42008057 0.97605878 1.46242556 3.56861318

## Example

Live Demo

x7<-rbinom(100,10,0.5)
x7

## Output

[1] 6 6 4 7 4 5 4 8 4 5 6 4 5 5 5 3 8 4 4 6 6 6 5 3 6
[26] 5 2 10 4 6 6 3 2 8 3 4 6 6 8 5 7 4 6 7 4 3 6 5 7 4
[51] 6 3 5 6 4 6 5 6 5 8 4 6 3 5 5 7 4 4 5 3 8 5 5 6 2
[76] 5 3 5 7 7 3 6 7 5 6 5 6 4 5 7 6 6 4 3 7 7 7 7 4 3

## example

quantile(x7,names=FALSE)

## Output

[1] 2 4 5 6 10

## Example

Live Demo

x8<-sample(1:12,100,replace=TRUE)
x8

## Output

[1] 5 11 2 12 2 12 10 3 6 7 4 3 10 1 11 8 3 10 3 12 10 12 10 12 3
[26] 10 11 7 8 7 6 10 6 7 1 11 12 3 11 9 3 2 3 5 5 8 4 8 12 7
[51] 11 5 5 10 9 8 3 3 9 6 7 9 10 5 7 1 12 12 9 5 10 9 1 4 2
[76] 5 3 8 11 10 8 7 2 5 1 6 4 2 10 1 2 10 5 10 12 3 7 1 6 4

## Example

quantile(x8,names=FALSE)

## Output

[1] 1 3 7 10 12

## Example

quantile(x8,c(0.25,0.50,0.75),names=FALSE)

## Output

[1] 3 7 10

## Example

quantile(x8,c(0.10,0.90),names=FALSE)

## Output

[1] 2.0 11.1

## Example

quantile(x8,c(0.05,0.50,0.95),names=FALSE)

## Output

[1] 1 7 12

## Example

Live Demo

x9<-sample(c(rnorm(10,2,5)),30,replace=TRUE)
x9

## Output

[1] 7.0402102 5.8762859 3.5496215 3.9135830 3.9135830 -1.9999648
[7] 3.5496215 -5.0834304 -1.9999648 8.0047440 8.0047440 -0.1738753
[13] 8.0047440 5.8762859 -0.1738753 -0.1738753 3.9135830 5.8762859
[19] -1.9999648 8.0047440 3.5496215 3.9135830 -1.9999648 6.5216414
[25] 3.5496215 5.8762859 -1.9999648 3.5496215 4.7756407 7.0402102

## Example

quantile(x9,names=FALSE)

## Output

[1] -5.0834304 -0.1738753 3.9135830 5.8762859 8.0047440

## Example

Live Demo

x10<-sample(c(rpois(10,5)),50,replace=TRUE)
x10

## Output

[1] 8 3 5 8 8 8 4 2 4 3 8 3 8 5 3 5 3 3 8 3 8 6 8 3 2 3 6 5 3 3 6 5 3 8 5 3 9 8
[39] 3 8 3 9 4 5 8 3 4 3 3 2

## Example

quantile(x10,names=FALSE)

## Output

[1] 2.0 3.0 4.5 8.0 9.0

Updated on: 08-Sep-2020

798 Views