Summary statistics

If you have a vector of numbers in R, there are many basic commands you can use to compute summary statistics. To illustrate, here is a vector of random numbers:

set.seed(20)
x <- rnorm(100)

Of course, these commands are useful no matter where the numbers came from:

sum(x) # the total of the numbers
[1] 0.4908104
mean(x) # the average of the numbers
[1] 0.004908104
var(x) # the variance
[1] 0.9799034
sd(x) # the standard deviation
[1] 0.9899007
median(x) # the median
[1] -0.02486056
max(x) # the biggest number
[1] 2.208443
min(x) # the smallest number
[1] -2.889718