I want to use functions from the expss
package in my own functions/packages. I usually call the functions along with their packages (e.g. dplyr::mutate(...)
).
The expss package has a function/operator %to%
, and I don't know how I can do the same here, i.e. expss::%to%
doesn't work, neither does expss::'%to%'
.
What can I do?
CodePudding user response:
Infix operators must be attached to be usable; you can’t use them prefixed with the package name.1
Inside a package, the conventional way is to add an importFrom
directive to your NAMESPACE
file or, if you’re using ‘roxygen2’, add the following Roxygen directive somewhere:
#' @importFrom expss %to%
Outside of package code, you could use ‘box’ to attach just the operator:
box::use(expss[`%to%`])
Or you can use simple assignment (this is the easiest solution in the simplest case but it becomes a lot of distracting code for multiple operators):
`%to%` = expss::`%to%`
1 Except using regular function call syntax:
expss::`%to%`(…)