I'm learning multivariate analysis. I am asked to calculate covariance of $$X=\begin{pmatrix} 3&7 \\ 2&4 \\ 4&7 \end{pmatrix}$$
According to P8 of Applied Multivariate Statistical Analysis written by Richard A. Johnson,
$$s_{ik}=\frac{1}{n}\sum^{n}_{j=1}(s_{ji}-\bar{x}_i)(s_{jk}-\bar{x}_k)$$ $i=1,2,\ldots,p$ , $k=1,2,\ldots,p$.
However, when I using R to compute covariance. It is following this formula $$s_{ik}=\frac{1}{n-1}\sum^{n}_{j=1}(s_{ji}-\bar{x}_i)(s_{jk}-\bar{x}_k) $$
I do not know why they are difference? How to determine when to use $\frac{1}{n}$ or $\frac{1}{n-1}$ ?