R Percentiles

📊 R Percentiles

Percentiles in R are used to understand the distribution of data by showing where a value lies relative to others.

They are widely used in statistics, exams, salaries, and data analysis.


 What is a Percentile?

  • A percentile indicates the value below which a given percentage of observations fall.

  • Example:

    • 25th percentile → 25% of values are below it

    • 50th percentile → Median

    • 75th percentile → 75% of values are below it


 Sample Data



 1. Percentiles Using quantile()

The quantile() function is used to calculate percentiles.


Output:

0% 25% 50% 75% 100%
10 20 30 40 50

  • 0% → Minimum

  • 50% → Median

  • 100% → Maximum


 2. Specific Percentile

25th Percentile


50th Percentile (Median)


75th Percentile



 3. Multiple Percentiles Together


✔ Gives 10th, 50th, and 90th percentiles


 4. Percentiles with Missing Values (NA)


 

📌 Use na.rm = TRUE to ignore missing values


 5. Percentiles in Data Frames


 


 6. Relationship with Boxplot

A boxplot is based on percentiles:

  • Bottom of box → 25th percentile (Q1)

  • Middle line → 50th percentile (Median)

  • Top of box → 75th percentile (Q3)



 


 7. When Are Percentiles Useful?

✔ Comparing exam scores
✔ Salary distribution analysis
✔ Detecting outliers
✔ Understanding data spread


📌 Summary

  • Percentiles show relative position of data

  • Use quantile() in R

  • 50th percentile = Median

  • Boxplots are percentile-based

  • Handle missing data with na.rm = TRUE

You may also like...