The function `dplyr::filter` is masked by `stats::filter`, how to change it?

it should not happen if you load the package in the correct order you want.
Restart your R session (this will detach all your current packages) and load the package in the order so that the last ones masked the first ones.

You should have a look at {conflicted} :package: too.

Useful if you have to deal with this kind of thing regularly.

The base R way is to reorder your environment, by putting dplyr above stats. Here is my order currently.

detach("package:dplyr")
library(dplyr)

will detach the :package: and re attach it above all other.

I let you dig into all this. Best advice is: Be used to work in a clean session regularly to avoid any conflicts or misplaced objects in workspaces.

7 Likes

And one more way to avoid it is, of course, use qualified calls, like dplyr::filter and leave unqualified filter to stats since it comes from base R.

3 Likes

This is a quick way to solve it, thanks @cderv

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.