我在使用R语言时,无法正确运行筛选函数,也不知道原因。我正在按照Kleiber和Zeileis(2008)的《应用计量经济学与R》一书中的示例进行操作,内容如下:
data("UKDriverDeaths")
lines(filter(UKDriverDeaths, c(1/2, rep(1, 11), 1/2)/12), col = 2)
在 R Studio 0.99.486 中,它给出了以下错误信息:
Error in lines(filter(UKDriverDeaths, c(1/2, rep(1, 11), 1/2)/12), col = 2) :
error in evaluating the argument 'x' in selecting a method for function 'lines': Error in UseMethod("filter_") :
no applicable method for 'filter_' applied to an object of class "ts"
在 R 3.2.2 中,它给了我这个错误:
Error in plot.xy(xy.coords(x, y), type = type, ...) :
plot.new has not been called yet
我通常使用R Studio,所以不确定'plot.new'错误是由于我对R 3.2.2的某些不理解导致的,但是对于R Studio错误,我不明白为什么错误显示“没有适用于'class"ts"'对象的'filter_'方法”,因为过滤函数专门用于时间序列。
这是否与我使用的R Studio版本有关呢?
如果能给予任何建议,我将不胜感激,因为这已经让我有点疯狂了。
filter
зљ„зЁ‹еєЏеЊ…гЂ‚иЇ·е°ќиЇ•дЅїз”Ёstats::filter
гЂ‚ - Tyler Rinkerdplyr
,则dplyr::filter
会掩盖stats::filter
。因此在加载时会出现这些消息。 - alistaire