Mean or arithmetic mean of a dataset is the average or central value of the discrete set of numbers. It can be found the sum of all number divided by total numbers. You can find Mean in R using a few simple steps.

To practice this, we assume that you have installed R on your computer and you have beginner level understanding with this language.

Even if you don’t have used the R before, this tutorial is very simple. You just have to follow the steps.

Find Mean in R – Example

Let’s assume there is a cruise ship Santa Maria with the people of following age group.

20,22,43,30,62,49,18,7,29,30

You are asked to find the average age of the passengers of this cruise ship.

The function mean() is used to calculate this Mean in R.

Step 1: Create a Vector in R

Vectors are generally created using the c() function. This must contain the same type of data. 

 

Remember: R is case-sensitive

x<-c(20,22,43,30,62,49,18,7,29,30)

Find Mean

 

mean(x)

Press enter and this will generate your output. This tutorial is for the smaller datasets. In upcoming tutorials, we will discuss finding the Mean Value using R in larger datasets which is the main purpose of using R.

If you have any query regarding this tutorial. Feel Free to ask.

Leave a Reply