# Geometric Mean in R (Geometric mean of column in R)

Geometric mean of the column in R is calculated using geometric.mean() function of the psych package. Let’s see how to calculate the Geometric mean of the dataframe in R and Geometric mean of the vector with an example of each.

Let’s first create the dataframe

```install.packages("psych")
library(psych)

df1 = data.frame(Name = c('George','Andrea', 'Micheal','Maggie','Ravi','Xien','Jalpa'),
Mathematics_score=c(45,78,44,89,66,49,72),
Science_score=c(56,52,45,88,33,90,47))

```

So the resultant dataframe will be

#### Geometric mean of the column in R:

Geometric mean of the Mathematics_score is calculated as shown below

```geometric.mean(df1\$Mathematics_score,na.rm=TRUE)
```

So the Geometric mean of the column will be

[1] 61.15899

#### Geometric mean of the vector in R:

```vector1 <- c(50,47,45,89,66,49,72)  # create vector
geometric.mean(vector1,na.rm=TRUE)
```

So the Geometric mean of the vector will be

[1] 57.93797

## Author

• With close to 10 years on Experience in data science and machine learning Have extensively worked on programming languages like R, Python (Pandas), SAS, Pyspark.