I was helping somebody with their code recently and they asked me why it was possible to use functions from a certain package (e.g. dplyr
) without explicitly 'loading' (and attaching them) to the search path within R.
Specifically, why it is possible to write:
dplyr::mutate(...)
As opposed to:
library(dplyr)
mutate(...)
When you use ::
, it doesn't appear to automatically 'attach' the functions from the namespace dplyr
onto the search path. That only happens when you call library()
. This confuses me slightly: when you use the ::
approach, how does R find the function mutate()
within dplyr
without it being attached to the search path?