Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Operator %>% not available although imported #723

grst opened this issue Mar 22, 2018 · 1 comment

Operator %>% not available although imported #723

grst opened this issue Mar 22, 2018 · 1 comment


Copy link

@grst grst commented Mar 22, 2018

I have a minimal R package


with test.R:

#' @import dplyr

#' A simple exported object
#' @export
my_object = c(2.0, 4.0) %>% mean()

and Imports: dplyr in my DESCRIPTION.

When I run

Rscript -e "library(devtools); document()"

I get the following error message:

Updating testpkg documentation
Loading testpkg
Error in c(2, 4) %>% mean() (from test.R#7) : could not find function "%>%"
Calls: document ... withr_with_dir -> force -> source_many -> source_one -> eval -> eval
Execution halted

Is that expected behaviour?

My understanding was that roxygen2 should write all imports to the NAMESPACE file, but it already fails before the NAMESPACE file is written, because a package is not loaded.

obviously, this affects any other function that is used outside a function() in test.R and is not limited to %>%.


If I use

#' A simple exported function
#' @export
my_function = function() {
  c(2.0, 5.0) %>% mean()

instead, everything works as expected.

Copy link

@hadley hadley commented Jun 28, 2018

Should work in the development version, although importing all of dplyr is ill-advised.

@hadley hadley closed this Jun 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants