So much time people need to calculate percentiles in statistics. This is a little as R failed to have no inbuilt function for that like quantiles and mean.
So how do we go about this?? Well some people accept the we should use the general formula
P(N+1)/100. Where p is the percentile value. They believe this will actually tell us the position of such percentiles.
However, this isn't always true infact most of the time it's not accurate.
Well, there is inbuilt function in R to do that but only few people aware of that.
What! There's inbuilt function for??
Don't doubt it, it's even what you know.
To calculate your percentiles use
quartile() function. inside it includes parameters called 'prob' and equal to your percentiles.
Our formula structure look like this
Let's take a look at some
Let say I need to find the 20 percentiles of the following data.
data=c(1,2,1,3,7,5,7,7,3,7,9,2,7,9,6,3,5,7,6,5,4,5,6,7,8,9,7,5,8,7) > quantile(data,0.2) 20% 3
Note: we are to change the percentage value to decimal, 20% =0.2. that is why we type 0.2.
Now let's try another example
find height of the 40 percentiles of the following heights.
allHeight=c(11,22,17,13,27,25,17,27,23,17,19,22,17,19,16,23,25,17,36,15,14,25,26,17,18,29,17,15,28,17) percent40=quantile(allHeight,0.4) print(percent40)
> percent40=quantile(allHeight,0.4) > print(percent40) 40% 17
can you see how easy it is to find your percentiles?? if you are given the following percentiles you type their respective value.
|percentiles||percent/100||value to be typed|
So always remember to convert your percentage to decimal.
To calculate quartile is a little thing in R. just used the quantile() function.
calculate the first quantile of the following heights.
> height=c(11,22,17,13,27,25,17,27,23,17,19,22,17,19,16,23,25,17,36,15,14,25,26,17,18,29,17,15,28,17) > print(quantile(height)) 0% 25% 50% 75% 100% 11.0 17.0 18.5 25.0 36.0
Note: the first quantile is below 25%, second quantile below 50%, third quantile is below 75%. etc.
I still get your back on that too but note the following fact.
The table above is show the equality between quantile and percentile. Therefore to find the first quantile in the previous question, we find the 25th percentile. so our codes look like the following
height=c(11,22,17,13,27,25,17,27,23,17,19,22,17,19,16,23,25,17,36,15,14,25,26,17,18,29,17,15,28,17) firstQuatile=quantile(height,0.25) print(firstQuantile)
> firstQuatile=quantile(height,0.25) > print(firstQuantile) Error in print(firstQuantile) : object 'firstQuantile' not found > print(firstQuatile) 25% 17
calculate the third quantile from the following data.
Firstly note that third quantile is equivalent to 75%. therefore we use 75% which is going to be change to 0.75.
mydata=c(1,2,1,3,7,5,7,7,3,7,9,2,7,9,6,3,5,7,6,5,4,5,6,7,8,9,7,5,8,7) thirdQuatile=quantile(height,0.25) print(thirdQuantile)
> mydata=c(1,2,1,3,7,5,7,7,3,7,9,2,7,9,6,3,5,7,6,5,4,5,6,7,8,9,7,5,8,7) > thirdQuantile=quantile(height,0.25) > print(thirdQuantile) 25% 17
Can you see how easy it is??.
well, we don't have any inbuilt function for decile too, However we can also use equaivalent percentile. how do we do that??? keep calm it is as easy as 1+1.
To Calculate Decile use quantile() function also. and input the conversion of your decile(in decimal ) inside the parameters.
first-Decile == 1/10 =0.1
second-Decile == 2/10 = 0.2
Third-Decile== 3/10 = 0.3.
you can continue the logic like that to finish all.
without wasting time, let's take a look at some question on this Decile.
calculate the third-decile of the following data.
we know that third decile is same as 3/10 i.e 0.3. therefore our codes will be the following
data=c(1,2,1,3,7,5,7,7,3,7,9,2,7,9,6,3,5,7,6,5,4,5,6,7,8,9,7,5,8,7) thirdDecile=quantile(data,0.3) print(thirdDecile)
>data=c(1,2,1,3,7,5,7,7,3,7,9,2,7,9,6,3,5,7,6,5,4,5,6,7,8,9,7,5,8,7) > thirdDecile=quantile(data,0.3) > print(thirdDecile) 30% 5
Now try to find the sixth,seventh,eighth and nineth decile.
How hope you find this article interesting?? you can chat me up to on whatsapp
(07045225718) or facebook to ask any question concerning or want to do any correction. thank you for reading.