请问有人那么友好,并指出这段代码的问题是什么
mav <- function(x, n = 5) { filter(x, rep(1 / n, n), sides = 1) }
Close <- c(21000, 23400, 26800, 21000, 23400, 26800)
SourceData <- data.frame(Close)
SourceData$CloseMA1 <- mav(SourceData$Close, n = 2)
我得到:
Error in UseMethod("filter_") :
no applicable method for 'filter_' applied to an object of class "c('double', 'numeric')"
答案 0 :(得分:4)
尝试stats::filter
。您还可以检查environment(filter)
中filter
来自哪个软件包。