![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to display upper and lower quartiles through different line in a boxplot in R?
To display the upper and lower quartiles through different line in base R boxplot, we can use abline function but we need to find the quartiles inside abline using quantile for the respective quartiles. The lines created by using abline and quantiles and the boxplot function may not coincide because of the differences in calculation. The calculation method for boxplot is explained below −
The two ‘hinges’ are versions of the first and third quartile. The hinges equal the quartiles for odd n (where n <- length(x)) and differ for even n. Whereas the quartiles only equal observations for n %% 4 == 1 (n = 1 mod 4), the hinges do so additionally for n %% 4 == 2 (n = 2 mod 4), and are in the middle of two observations otherwise.
Example
> x<-rnorm(100) > boxplot(x)
Output
Example
> abline(h=quantile(x,c(0.25,0.75)),col="blue")
Output
Advertisements