R Language

Using pipe assignment in your own package %<>%: How to ?

Introduction#

In order to use the pipe in a user-created package, it must be listed in the NAMESPACE like any other function you choose to import.

Putting the pipe in a utility-functions file

One option for doing this is to export the pipe from within the package itself. This may be done in the ‘traditional’ zzz.R or utils.R files that many packages utilise for useful little functions that are not exported as part of the package. For example, putting:

#' Pipe operator
#'
#' @name %>%
#' @rdname pipe
#' @keywords internal
#' @export
#' @importFrom magrittr %>%
#' @usage lhs \%>\% rhs
NULL

This modified text is an extract of the original Stack Overflow Documentation created by the contributors and released under CC BY-SA 3.0 This website is not affiliated with Stack Overflow