# Calculate Arithmetic mean in R Programming – mean() Function

`mean()` function in R Language is used to calculate the arithmetic mean of the elements of the numeric vector passed to it as argument.

Syntax: mean(x, na.rm)

Parameters:
x: Numeric Vector
na.rm: Boolean value to ignore NA value

Example 1:

 `# R program to calculate ` `# Arithmetic mean of a vector ` ` `  `# Creating a numeric vector ` `x1 <``-` `c(``1``, ``2``, ``3``, ``4``, ``5``, ``6``) ` `x2 <``-``c(``1.2``, ``2.3``, ``3.4``, ``4.5``) ` `x3 <``-` `c(``-``1``, ``-``2``, ``-``3``, ``-``4``, ``-``5``, ``-``6``) ` ` `  `# Calling mean() function ` `mean(x1) ` `mean(x2) ` `mean(x3) `

Output:

``` 3.5
 2.85
 -3.5
```

Example 2:

 `# R program to calculate ` `# Arithmetic mean of a vector ` ` `  `# Creating a numeric vector ` `x1 <``-` `c(``1``, ``2``, ``3``, NA, ``5``, NA, NA) ` ` `  `# Calling mean() function ` `# including NA values ` `mean(x1, na.rm ``=` `FALSE) ` ` `  `# Calling mean() function ` `# excluding NA values ` `mean(x1, na.rm ``=` `TRUE) `

Output:

``` NA
 2.75
```
My Personal Notes arrow_drop_up Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

Article Tags :

Be the First to upvote.

Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.