//Mean Value with R

Mean Value with R

In this example I’ll show you how to find the average value of a vector using R language. First we declare a vector with the numbers we want to find the average of and write in the variable a. The declaration of the vector is obtained by the command “c” (derived from “combine”). The assignment to the variable is performed with the ” <- “operator. The command to find the average value in R language is “mean”.

> a<-c(1:10)
> mean(a)
[1] 5.5

In the example above, we initialize the vector with the numbers 1 to 10. Then we find their average value, which is 5.5.

By |2018-12-03T22:43:24+00:00May 8th, 2017|Categories: How To|Tags: , |0 Comments

Leave A Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

We use cookies on this site to improve our service, perform analytics and remember website preference. By using the site, you consent to these cookies. I consent to cookies