R 中的 rollmin 类似于动物园包 rollmax [英] rollmin in R similar to zoo package rollmax

查看:30
本文介绍了R 中的 rollmin 类似于动物园包 rollmax的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

rollmin 是否有与 zoo 包中的 rollmean 和 rollmax 工作方式相同的函数?我查看了动物园帮助文档,但找不到任何内容.

Is there a function for rollmin in the same way rollmean and rollmax work from the zoo package? I've looked into the zoo help document but can't find anything.

推荐答案

对值的负数运行 rollmax ,然后否定结果.例如,

Run rollmax on the negative of the values and then negate the result. For example,

library(zoo)

 x <- 1:10

-rollmaxr(-x, 3, fill = NA)
## [1] NA NA  1  2  3  4  5  6  7  8

另一种可能性是将 rollapplymin 函数一起使用:

Another possibility is to use rollapply with the min function:

rollapplyr(x, 3, min, fill = NA)
## [1] NA NA  1  2  3  4  5  6  7  8

这篇关于R 中的 rollmin 类似于动物园包 rollmax的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆