-1

I have vector $x=[3, 5, 7, 8, 12, 13, 14, 18, 21]$ and wanted to see summary statistics.

if I use summary(x) function in R, My anwser

 Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
   3.00    7.00   12.00   11.22   14.00   21.00

But actual anwser is Q1 = 6 and Q2=16

What is the difference ?

deemel
  • 2,402
  • 4
  • 20
  • 37
SCOTT
  • 1
  • 2
  • 1
    See [this page](https://stats.stackexchange.com/q/134229/28500) among others on this site for an answer. – EdM May 14 '18 at 13:35

1 Answers1

1

x is ordered and has $N = 9$.

The median is the element of position $(N + 1) / 2 = 5$, i.e. $12$.

The half samples $\{3,\, 5,\, 7,\, 8,\, 12\}$ and $\{12,\, 13,\, 14,\, 18,\, 21\}$ have $n = 5$.

The median of the half samples, i.e. $Q_1$ and $Q_3$ of x, are the elements of position $(n + 1) / 2 = 3$, i.e. $7$ and $14$, as returned by sample(x).

ocram
  • 19,898
  • 5
  • 76
  • 77
  • x summary(x) Min. 1st Qu. Median Mean 3rd Qu. Max. 1.000 2.250 3.500 3.167 4.000 5.000 In this case how it works please explain? @ocram – SCOTT May 14 '18 at 13:45
  • 1
    Please type `help(quantile)` at the `R` console and see the different approaches to that problem, that `R` has to offer. The heading "Types" is the most relevant one. – Bernhard May 14 '18 at 14:43