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

no visible binding for global variable for CRAN check #57

Open
kongdd opened this issue Jul 18, 2021 · 2 comments
Open

no visible binding for global variable for CRAN check #57

kongdd opened this issue Jul 18, 2021 · 2 comments

Comments

@kongdd
Copy link

kongdd commented Jul 18, 2021

when using zeallot, package can't pass CRAN check:

c(d_fit, info_peak) %<-% rough_fitting(INPUT)
# checking R code for possible problems ... NOTE
opt_season: no visible binding for global variable 'd_fit'
opt_season: no visible binding for global variable 'info_peak'

Undefined global functions or variables:
d_fit info_peak

Any suggestions?

joeroe added a commit to joeroe/cleanc14 that referenced this issue Mar 7, 2022
Causes an R CMD check note: r-lib/zeallot#57

Also specify where c14_lab_code thesaurus comes from, for the same reason.
@markfairbanks
Copy link

To pass CRAN checks you just need to use globalVariables() somewhere in your package to let CRAN checks know to ignore these variables.

your_function <- function(val) {
  c(d_fit, info_peak) %<-% rough_fitting(INPUT)
}

globalVariables(c("d_fit", "info_peak"))

You can specify all such variables throughout your package in a single globalVariables() call, or you can use it multiple times throughout the package.

@wleoncio
Copy link

Using globalVariables() is quite a controversial thing. The documentation for the function itself gives an example involving some local variables that codetools fails to find, but ends up stating that "it is much better practice to write code that can be checked thoroughly". In any case, I feel it's improper to declare variables as global when they are not.

Another solution would be to simply initialize the variables before the assignment:

d_fit <- info_peak <- NA  # or whatever makes more sense than NA
c(d_fit, info_peak) %<-% rough_fitting(INPUT)

wleoncio added a commit to ocbe-uio/rBAPS that referenced this issue Dec 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants