
Jacob W. answered 01/14/20
Quantitative Invasion Ecologist with 8 years R Programming Experience
Let's say you want to calculate the mean and median for the following set of values: 1, 5, 8, 9, 2.
To calculate the mean you can type the following commands into the R command line or console:
mean(c(1, 5, 8, 9, 2))
median(c(1, 5, 8, 9, 2))
To avoid repeating yourself, you could first assign that list of numbers to an object that we will call x:
x <- c(1, 5, 8, 9, 2)
And then type:
mean(x)
median(x)