To illustrate the ‘mean’ of a distribution use the dataset ‘rivers’ which is a part of the base installation:

mean(rivers)
## [1] 591.1844

Find the ‘median’ of the same ‘rivers’ dataset:

median(rivers)
## [1] 425

One way of finding the ‘mode’ is the following:

names(rev(sort(table(rivers))))[1]
## [1] "360"

table(rivers) creates a table of the frequencies of each value, the table is sorted and then reversed putting the largest value first, then names(…)[1] picks off the first element. The result is a string so it might need to be converted by the as.numeric() function.

It is always a good idea to check the shape of the distribution using a function like hist

hist(rivers)