nohomejerome
nohomejerome

Reputation: 141

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

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?

Upvotes: 3

Views: 745

Answers (1)

G. Grothendieck
G. Grothendieck

Reputation: 269654

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.

Upvotes: 5

Related Questions