In: Statistics and Probability
how to find the first, second, third quantile of a column in a dataset with R?
the dataset is like this:
columns values
a. 1. 2. 3. 5. 6. 7. 4. 7. 8. .........
b 5. 6. 7. 3. 8. 0. 4. 7. 4. 7. .........
c 1. 2. 3. 5. 6. 7. 4. 7. 8. .........
d 6. 3. 1. 0. 8. 3. 6. 6. 3.........
a. 1, 2, 3, 5, 6, 7, 4, 7, 8.
The first quartile, or lower quartile, is the value that cuts off the first 25% of the data when it is sorted in ascending order. The second quartile, or median, is the value that cuts off the first 50%. The third quartile, or upper quartile, is the value that cuts off the first 75%.
R code:
> x<-c(1,2,3,5,6,7,4,7,8)
> quantile(x)
0% 25% 50% 75% 100%
1 3 5 7 8
The first, second and third quartile are 3, 5 and 7 respectively.
b) 5, 6, 7, 3, 8, 0, 4, 7, 4, 7.
R-code:
>x<-c(5,6,7,3,8,0,4,7,4,7)
> quantile(x)
0% 25% 50% 75% 100%
0.0 4.0 5.5 7.0 8.0
The first, second and third quartile are 4, 5.5 and 7 respectively.
c) 1, 2, 3, 5, 6, 7, 4, 7, 8
R-code:
>x<-c(1,2,3,5,6,7,4,7,8)
> quantile(x)
0% 25% 50% 75% 100%
1 3 5 7 8
The first, second and third quartile are 3, 5 and 7 respectively.
d) 6, 3, 1, 0, 8, 3, 6, 6, 3
R-code:
>a<-c(6,3,1,0,8,3,6,6,3)
> quantile(a)
0% 25% 50% 75% 100%
0 3 3 6 8
The first, second and third quartile are 3, 3 and 6 respectively.