1

I am trying to create an R package from scripts using RStudio and Devtools and trying to follow advice from Hadley Wickam's Package book.

One of the functions in my package (located at a ./R/fuctions.R) contains the piping operator (%>%), as well as other dplyr functions. However, after loading the functions, devtools::load_all(), and trying to test the function I get the following error:

Error in function_name(2014) : could not find function "%>%"

I already included the dependencies for dplyr and magrittr in both, DEPENDENCIES and NAMESPECE as in:

DESCRIPTION

Imports:
  dplyr,
  magrittr

NAMESPACE

#' @import dplyr
#' @import magrittr)

How can I make "%>%" work within a package?

LucasMation
  • 2,408
  • 2
  • 22
  • 45
  • do you need the backticks around the operator: `magrittr::\`%>%\`` – SymbolixAU May 30 '16 at 03:52
  • I tried variations of your suggestion magrittr::`%>%`, `%>%`, '%>%', \%>\% . None of them worked. With %>%, or any of these variations, devtools::load_all() does not work – LucasMation May 30 '16 at 04:11
  • 2
    maybe [this answer](http://stackoverflow.com/a/27979637/5977215) helps? (which could mean this question is a duplicate) – SymbolixAU May 30 '16 at 04:13
  • 1
    yes, the answer there works. Tks a lot (I don´t know how I missed that, I had been googling for a while). I'll let more experienced users decide if this question should be deleted or just pointed to the other one. Tks – LucasMation May 30 '16 at 04:53

0 Answers0