[R-pkg-devel] CRAN pre-test failed on NOTE "no visible binding for global variable"

Georgi Boshnakov georg|@bo@hn@kov @end|ng |rom m@nche@ter@@c@uk
Tue Jul 2 17:00:36 CEST 2019


> ...
> if(getRversion() >= "2.15.1") utils::globalVariables(c("."))

Using such a general pattern eventually and  inevitably will prevent the check from reporting legitimate bugs. 
One alternative is to list explicitly the variables in question and make sure that they are not commonly used names like 'x'. 
If that is not practical and you use non-standard evaluation a lot,  consider '.data' from package 'lang' , see its documentation and/or Google it 
to find out how to use it. 

#' @importFrom rlang .data


Georgi Boshnakov

-----Original Message-----
From: R-package-devel [mailto:r-package-devel-bounces using r-project.org] On Behalf Of Iñaki Ucar
Sent: 02 July 2019 15:19
To: Berlanga, Antonio J
Cc: r-package-devel using r-project.org
Subject: Re: [R-pkg-devel] CRAN pre-test failed on NOTE "no visible binding for global variable"

raúl

On Tue, 2 Jul 2019 at 14:18, Berlanga, Antonio J
<a.berlanga using imperial.ac.uk> wrote:
>
> Hi r-package-devel,
>
> I've submitted my first package but it failed the CRAN pre-tests on
> NOTES. I got:
>
> - my email
>
> - an extra non-standard file (which I have now added to .Rbuildignore)
>
> - NOTEs on "no visible global function definition"
>
> The first two I assume are harmless. The third I do not know how to fix
> (possible solutions below). Can it be ignored and suggest the fail was a
> false-positive?
>
> The third NOTE is:
>
> #######
>
> Flavor: r-devel-linux-x86_64-debian-gcc, r-devel-windows-ix86+x86_64
> Check: R code for possible problems, Result: NOTE
>   epi_clean_count_classes: no visible global function definition for
>     '%>%'
>   epi_clean_count_classes: no visible binding for global variable '.'
>   epi_plot_heatmap: no visible binding for global variable 'Var1'
>   epi_plot_heatmap: no visible binding for global variable 'Var2'
>   epi_plot_heatmap: no visible binding for global variable 'value'
>   epi_plot_heatmap_triangle: no visible binding for global variable
>     'Var1'
>   epi_plot_heatmap_triangle: no visible binding for global variable
>     'Var2'
>   epi_plot_heatmap_triangle: no visible binding for global variable
>     'value'
>   epi_plot_heatmap_triangle: no visible global function definition for
>     'element_text'
>   epi_plot_heatmap_triangle: no visible global function definition for
>     'coord_fixed'
>   epi_plot_heatmap_triangle: no visible global function definition for
>     'element_blank'
>   epi_plot_heatmap_triangle: no visible global function definition for
>     'element_rect'
>   epi_plot_heatmap_triangle: no visible global function definition for
>     'guide_colorbar'
>   epi_stats_summary: no visible global function definition for '%>%'
>   epi_stats_tidy: no visible global function definition for '%>%'
>   epi_stats_tidy: no visible binding for global variable '.'
>   epi_stats_tidy: no visible binding for global variable 'x'
>   epi_stats_tidy: no visible binding for global variable 'n'
>   epi_stats_tidy: no visible binding for global variable 'id'
>   Undefined global functions or variables:
>     %>% . Var1 Var2 coord_fixed element_blank element_rect element_text
>     guide_colorbar id n value x
> #######
>
>
> Solutions seem to cause errors elsewhere and there does not appear to be
> an ideal one unfortunately. It seems to me that adding a file in the
> directory 'R' containing eg:
>
> #######
>
> if(getRversion() >= "2.15.1") utils::globalVariables(c("."))
>
> #######
>
> is one of the preferred ways. This seems far from ideal though.

If you use NSE in your package, this is the best solution. You may
also switch to SE.

Iñaki

______________________________________________
R-package-devel using r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel


More information about the R-package-devel mailing list