2

I am trying to create a package ("packagename") to host some custom R functions and R markdown templates. I am trying to use magrittr pipe in one of the functions in it. For this, I am using

usethis::use_pipe()

function. However, when I try to build this package, I get error as follows: -

Error in loadNamespace(x) : there is no package called 'usethis'
Error: unable to load R code in package 'packagename'
Execution halted
ERROR: lazy loading failed for package 'packagename'
* removing 'path/to/my/package.Rcheck/packagename'

How can I get rid of this error?

Eva
  • 663
  • 5
  • 13
  • 2
    Could you use `importFrom(magrittr,"%>%")` in your NAMESPACE file (and declare the import in the DESCRIPTION file) or if you're using roxygen, you could use `#' @importFrom Magritte %>%` in your R file. – DaveArmstrong May 13 '22 at 10:26
  • Have you installed the package usethis? – phiver May 13 '22 at 10:32
  • Yes, usethis package is already installed. @phiver – Eva May 13 '22 at 10:44
  • 1
    You probably shouldn't use any `usethis` functions in your package code. It's designed for interactive use, to set you up to do other things. In particular, `usethis::use_pipe` is designed to modify your package code so that `magrittr` pipes are available. – user2554330 May 13 '22 at 11:35
  • Yeah, where exactly did you put `usethis::use_pipe()`? It should *not* be in the code for your package. That's a command you run in R to configure the metadata of your package. – MrFlick May 13 '22 at 14:24
  • You need to have a package documentation file using [`usethis::use_package_doc`](https://usethis.r-lib.org/reference/use_package_doc.html). If you already have that, then use `usethis::use_pipe()`. Then you have to use `devtools::document()`. Then it should work. – Mossa May 13 '22 at 14:40

0 Answers0