How to use geometric.mean Function of psych Package In R Language

In this approach, the user has to first install and import the psych package in the working R console, then the user has to call the geometric.mean() function with the required parameter passed into it to calculate the geometric mean of the given data. 

Syntax to install and import the psych package:

install.package('psych')
library('psych')

Syntax:

geometric.mean(data)

Example:

In this example, we will be calculating the geometric mean of 5 elements in the vector using the geometric.mean() function from the psych package in the R programming language.

R




# load the library
library(psych)
  
# create  vector
data=c(1,2,3,4,5)
  
# calculate geometric mean
geometric.mean(data)


Output:

[1] 2.605171

How to Calculate Geometric Mean in R?

In this article, we will discuss how to calculate the Geometric Mean in R Programming Language.

We can define the geometric mean as the average rate of return of a set of values calculated using the products of the terms.

Similar Reads

Method 1: Compute Geometric Mean Manually

In this method, the user can calculate manually by using exp(), mean() and log() functions together by passing the parameter as the given data to calculate the geometric mean in the R programming language....

Method 2: Using geometric.mean Function of psych Package

...

Method 3: Calculate Geometric Mean of Columns in Data Frame

In this approach, the user has to first install and import the psych package in the working R console, then the user has to call the geometric.mean() function with the required parameter passed into it to calculate the geometric mean of the given data....