## Sunday, July 19, 2009

### Let us practice with some functions of R

Given the following data set, compute the arithmetic mean, median, variance, standard deviation; find the greatest and the smaller value, the sum of all values, the square of the sum of all values, the sum of the square of all values; assigne the ranks and add them, assigning the ranks to the first 6 values and add those.

10, 2, 19, 24, 6, 23, 47, 24, 54, 77

Extremely simple to perform in R, deliberately created to familiarize with some statistical functions that can serve us in the future. Not carry over mathematical formulas, which you can find in any book of mathematics, or Wikipedia.

`a = c(10, 2, 19, 24, 6, 23, 47, 24, 54, 77)mean(a) #calculate the arithmetic mean 28.6median(a) #calculate the median 23.5var(a) #calculate the variance 561.8222sd(a) #calculate the standard deviation 23.70279max(a) #shows the larger value of the sequence 77min(a) #shows the smallest value of the sequence 2sum(a) #sum all the values 286sum(a)*sum(a) #calculates the square of the sum of all values 81796sum(a*a) #calculates the sum of the squares of all values 13236sum(rank(a)) #sum of ranks assigned to the variables contained in a 55sum(rank(a)[1:6]) #sum of ranks assigned to the first 6 values of a 21.5`