简体   繁体   中英

R how to select functions between conflicting libraries

When writing scripts on R,

I had trouble choosing functions with overlapping packages.

For example,

library(dplyr)
library(tidyverse)
~~~~~

And in the console,

-- Conflicts ---------------------------- tidyverse_conflicts() ---
x dplyr::filter() masks stats::filter()
x dplyr::lag() masks stats::lag()
~~~~

How can I select the right functions? For example, I want "filter()" from dplyr and lag() from stats.

*ps I don't want to write library() every time

If you don't want to use dplyr::filter every time, we can use the {conflicted} package .

library(dplyr)
conflict_prefer("filter", "dplyr")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM