[R-pkg-devel] dplyr usage inside another package

Uwe Ligges ligges at statistik.tu-dortmund.de
Tue Aug 11 01:10:17 CEST 2015


On 11.08.2015 00:35, Jonathan Callahan wrote:
> Greetings,
>
> I'm using dplyr inside of another package with examples like this:
>
> data <- dplyr::filter(data, datetime >= trange[1], datetime <= trange[2])
>
>
> When I run my package through R CMD check I get the following NOTES:
>
> monitorSubsetData: no visible binding for global variable ‘datetime’
>
>
> I already have dplyr listed in the package Depends: section of the
> DESCRIPTION.
>
> I'm also encountering
>
> no visible global function definition for ‘matches’
>
>
> when I try to use the dplyr internal function matches().
>
> Is there any way to allow for dplyr syntactic sugar inside of my package

You can, but this is non-standard reference to datetime the codetools do 
not anticipate and hence you need to declare it via globalVariables().


> or
> do I need to be pedantic and say data$datetime in the first example and
> dplyr::matches in the second? (Will dplyr::matches even work when it is not
> an exported function?)

If it is any package you use in private you can use triple colons. If 
you want the package to be published on CRAN, then you must not use 
non-exported functions (hence not in the API of the package).

Best,
Uwe Ligges


> Thanks,
>
> Jon
>



More information about the R-package-devel mailing list