2

I had the dplyr package loaded when I loaded the stringi package. This message appeared (I dropped a couple of lines re ggplot2 being masked for %+%).

require(stringi)
Loading required package: stringi

Attaching package: ‘stringi’

The following object is masked from ‘package:dplyr’:

    %>%

When I returned to using dplyr, I reloaded it.

require(dplyr)

Why did that last call not warn me that %>% is masked from stringi?

More generally, if you don't remember to reload a package (and presumably restore its use of some function masked by another package, how do you figure out the masking?

lawyeR
  • 7,488
  • 5
  • 33
  • 63
  • 4
    If you call `library` or `require` for an already loaded package, the package is not reloaded. Since masking only occurs when a package is loaded, `%>%` will not be masked when you try to reload `dplyr`. If you need to refer to `dplyr`'s `%>%` function, you can use `dplyr::'%>%'` or make sure you're loading `dplyr` after `stringi`. – tkmckenzie Jul 25 '14 at 17:05
  • I would just not try to figure it out, and open a fresh R session. And maybe re-name some functions that do different things but have the same name. Did you unload and detach both packages first? – Rich Scriven Jul 25 '14 at 17:07
  • @RichardScriven. Good point. I did not detach stringi, which I assume would have unmasked %>% for the already loaded dplyr. I have also found that the reorder function I use so much in ggplot gets masked. I add stats:: and all is well. How can I find what package has masked reorder()? – lawyeR Jul 25 '14 at 17:25
  • you figure out the masking by the order of the packages in `search()`, or just type `\`%>%\`` and see what the code looks like or which namespace it resides in, or `environment(\`%>%\`)` – rawr Jul 25 '14 at 17:26
  • @tkmckenzie: if you put this in an answer I will accept it. I just realized I have not done anything except learn from this. Thanks – lawyeR Sep 13 '14 at 02:04

1 Answers1

3

You can reload dplyr using the devtools package.

library(devtools)
reload(inst("dplyr"))
jayelm
  • 7,236
  • 5
  • 43
  • 61
wdkrnls
  • 4,548
  • 7
  • 36
  • 64