Conflict in libraries dplyr::lag() and stats::lag()

Viewed 228
library(dplyr)
library(stats)

I am running a lot of regressions with a lagged variable and my R console has a conflict with the above packages. I know that I can circumvent this problem by typing "dplyr::lag()" for every regression.

However, is there another solution to this?

1 Answers

Given that dplyr is at fault here for clobbering lag I would do it like this:

library(dplyr, exclude = c("filter", "lag"))
Lag <- dplyr::lag

Now you can use lag as usual and when you want to use dplyr's lag just use Lag.

Related