Chapter 15. Basic Statistics
Some of the most common tools used in statistics are means, variances, correlations and t-tests. These are all well represented in R
with easy-to-use functions such as mean
, var
, cor
and t.test
.
15.1. Summary Statistics
The first thing many people think of in relation to statistics is the average, or mean, as it is properly called. We start by looking at some simple numbers and later in the chapter play with bigger datasets. First we generate a random sampling of 100 numbers between 1 and 100.
> x <- sample(x = 1:100, size = 100, replace = TRUE)> x [1] 93 98 84 62 18 12 40 13 30 4 95 18 55 46 2 24[17] 54 91 9 57 74 6 11 38 67 13 40 87 2 85 4 6[33] 61 28 37 61 10 87 41 10 11 4 37 84 54 69 21 33 ...
Get R for Everyone: Advanced Analytics and Graphics now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.