Skip to content
This repository has been archived by the owner on Feb 13, 2020. It is now read-only.

Loading tidyverse package: Conflicts with tidy/dplyr messages? #331

Open
NicoleOngUBC opened this issue Sep 22, 2016 · 4 comments
Open

Loading tidyverse package: Conflicts with tidy/dplyr messages? #331

NicoleOngUBC opened this issue Sep 22, 2016 · 4 comments

Comments

@NicoleOngUBC
Copy link

Output in my console when I load tidyverse in a new R session.

library(tidyverse)
Loading tidyverse: ggplot2
Loading tidyverse: tibble
Loading tidyverse: tidyr
Loading tidyverse: readr
Loading tidyverse: purrr
Loading tidyverse: dplyr
Conflicts with tidy packages ---------------------------------------------------------
filter(): dplyr, stats
lag(): dplyr, stats

Is this a normal "conflict" message re. tidy packages?

@oganm
Copy link
Member

oganm commented Sep 22, 2016

When you load a package, if functions in the library share names with any base R functions or any other functions in loaded packages they warn you of the conflict and they replace them as the default function that will be called when you write their names. Functions with names filter and lag exist in base R which means they will always conflict with dplyr functions.

Normally when making packages, you don't want to give your functions the same names as anything that is in base R or any popular packages as this would cause confusion and annoyance to users, but I assume Hadley (creator of dplyr) doesn't think you'd be using base R's filter or lag when you have load dplyr since they do more or less the same thing.

When a conflict happens, in order to use the functions that were "masked" you need to do packageName::functionName, in this case stats::filter or stats::lag

@jennybc
Copy link
Member

jennybc commented Sep 22, 2016

Yes this is normal. I was getting that too.

Better reporting of conflicts is, in fact, one of the motivations for making the tidyverse meta-package.

As @oganm says, this is your incessant reminder that, if you want to access one of those masked functions, you will need to do so with explicit namespace qualification as he shows: stats::lag().

@NicoleOngUBC
Copy link
Author

Got it! Thanks for the really prompt responses!!

@yeedle
Copy link

yeedle commented Jan 2, 2017

For some weird reason, dplyr's filter and lag get masked when i load tidyverse instead of the ones from stats. What gives?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants