Geometric Mean This functions creates a geometric mean of a numeric vector.

Usage,
geom_mean(x, roll_window = length(x))

Arguments

x

numeric vector or dataframe column.

roll_window

numeric - length of the vector, or can be used to build a rolling geometric mean.

Value

Returns the geometric mean of a vector, or one number.

Examples

library(tibbletime)
#> 
#> Attaching package: 'tibbletime'
#> The following object is masked from 'package:stats':
#> 
#>     filter
library(purrr)
#> 
#> Attaching package: 'purrr'
#> The following object is masked from 'package:magrittr':
#> 
#>     set_names
geom_mean_3 <- purrr::partial(geom_mean, roll_window = 3)
geom_mean_roll_3 <- tibbletime::rollify(geom_mean_3,window = 3)
data <- c(20,25,38,15,70)
geom_mean(data)
#> [1] 32.25845
geom_mean_roll_3(data)
#> [1]       NA       NA 27.44519 25.64995 39.21155