I've used usethis::use_pipe()
to create a file utils-pipe.R
that loads the magrittr pipe.
utils-pipe.R
#' Pipe operator
#'
#' See \code{magrittr::\link[magrittr:pipe]{\%>\%}} for details.
#'
#' @name %>%
#' @rdname pipe
#' @keywords internal
#' @importFrom magrittr %>%
#' @export
#' @usage lhs \%>\% rhs
#' @param lhs A value or the magrittr placeholder.
#' @param rhs A function call using the magrittr semantics.
#' @return The result of calling `rhs(lhs)`.
NULL
I've also got magrittr
in the Imports:
section of the DESCRIPTION file.
Imports
Imports:
dplyr,
jogger,
here,
magrittr,
purrr,
sf,
tmap
When I am in my package project in RStudio, and I use devtools::load_all(".")
, and then try to run a line of code using %>%
, I get the error:
could not find function "%>%"
If I then actually attach the package with library()
and run the line of code, I still get the error.
My belief was that either load_all()
or library($my_pkg)
ought to load the pipe and avoid this error. I've also not had this problem in other packages I've developed.
I can get round it by doing library(dplyr)
or whatever, but I'd like to correct my understanding and work out why the pipe is not already loaded. Any ideas please?