0

I have this code in R:

data <- c(55, 64, 68, 74, 78, 80, 84, 90, 93, 95)
summary(data)

I was expecting the Median to be 79, 1st Quartile to be 68 and 3rd Quartile to be 90 according to my previous knowledge.

What I got as an output was 79 for the median, but the 1st quartile came out to be 69.5 and 3rd quartile came out to be 88.5.

I cannot figure out how this output has been generated. Can anyone out there help me with this?

Shahbaz Hussain
  • 542
  • 4
  • 21
  • 1
    What does the help file for quantile tell you about this? – Elin Apr 03 '18 at 18:57
  • 1
    the help file for `median` points to the `quantile` function. The `quantile` help file discusses the `type` argument, and R uses type 7 as a default. It's a different algorithm than what you expect, is all. You could read more about the seven types by reading the Wikipedia entry for "Quantile" – Benjamin Apr 03 '18 at 18:57
  • There are different ways to calculate quantiles. Your method doesn't match the built in default. – Dason Apr 03 '18 at 19:00
  • @Dason I want to know about that built-in default method actually, I mean how does that summary function calculates quartile? – Shahbaz Hussain Apr 03 '18 at 19:02
  • Thanks all I got the answer, it was indeed the type 7 thing, I figured out how type 7 works for calculating quartiles. – Shahbaz Hussain Apr 03 '18 at 19:29

0 Answers0