LoginSignup
1
3

More than 5 years have passed since last update.

Rのfilter()関数について

Posted at

Rで移動平均を計算したい時に便利なのが、filter()関数です。
この関数を使うと、引数で指定した通りに重み付けをして平均してくれますが、パッケージdplyrを読み込んだあとではエラーで使えないことがわかった。

aaa <- rnorm(100, mean=10, sd=4)
filter(aaa, c(1,1,1))
UseMethod("filter_") でエラー:
'filter_' をクラス "c('double', 'numeric')" のオブジェクトに適用できるようなメソッドがありません

なので、dplyrパッケージを一旦detach()でunloadしてから使わなければならないようです。

1
3
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
3