'How can I use magrittr pipe (%>%) in my package?

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?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source