Geometric Mean: is there a built-in?

前端 未结 9 1752
走了就别回头了
走了就别回头了 2020-11-28 20:45

I tried to find a built-in for geometric mean but couldn\'t.

(Obviously a built-in isn\'t going to save me any time while working in the shell, nor do I suspect ther

9条回答
  •  夕颜
    夕颜 (楼主)
    2020-11-28 21:01

    In case there is missing values in your data, this is not a rare case. you need to add one more argument.

    You may try following code:

    exp(mean(log(i[ is.finite(log(i)) ]), na.rm = TRUE))
    

提交回复
热议问题