6

I wrote an R package, which is based on dplyr. When I run the CMD check, an error pops up when evaluating the @examples.

could not find function "%>%"
Calls: Rresult
Execution halted

I have added dplyr in the description file, and the package works well when I run the examples myself. I don't know where the problem is.

Here is part of my description file:

Imports:
stats,
utils,
dplyr

As a matter of fact, during CMD check, some notes on no visible binding for global variable also appeared, which are related to dplyr package. For instance

Rresult: no visible global function definition for ‘group_by’
Undefined global functions or variables:
group_by

I used following code to remove the notes:

group_by <- filter_at <- "%>%" <- NULL

Thanks a lot for your help

Wang
  • 1,314
  • 14
  • 21

1 Answers1

4

Add this to the script that contains the function(unless you imported the entire dplyr).

@importFrom magrittr "%>%"

If you intend to use dplyr functions maybe explicitly call them like:

dplyr::group_by
dplyr::filter_at
NelsonGon
  • 13,015
  • 7
  • 27
  • 57
  • Unfortunately, it did not help. @NelsonGon – Wang Feb 07 '19 at 17:48
  • I assume you're using `roxygen2` and `devtools` – NelsonGon Feb 07 '19 at 17:48
  • Could you edit to say exactly where the notes were? I can't seem to get the purpose of this block: `group_by <- filter_at <- "%>%" <- NULL` – NelsonGon Feb 07 '19 at 17:53
  • Check if the edit helps! because it seems to me you set the `pipe` to NULL – NelsonGon Feb 07 '19 at 17:59
  • 1
    @ NelsonGon, thanks a lot for your help. With your script, I have found the problem. One of my dependency package `xcms` happens to have several same function names as `dplyr`. therefore some functions in `dplyr` have been replaced. – Wang Feb 07 '19 at 18:26