I'm throwing in another 1 cent. I agree that utils::globalVariables() is risky; since it goes in the root of the package code, it applies to *all* functions in the package, which is a bit too broad of a stroke for my taste. The way I deal with false globals from non-standard evaluation (NSE), is to declare them a as dummy variables local to the function. In this case, I would use:
myfcn <- function() { ## To please R CMD check mpg <- cyl <- NULL mtcars |> select(mpg, cyl) |> head(3) } ADVANCED: To avoid those dummy assignments from taking place in every call, one can also do: myfcn <- local({ ## To please R CMD check mpg <- cyl <- NULL function() { mtcars |> select(mpg, cyl) |> head(3) } }) which is also a bit cleaner, because it keeps the original function body as-is. REALLY ADVANCED: If you want to be fancy, you can even protect against mistakes by using: myfcn <- local({ ## To please R CMD check mpg <- cyl <- NULL ## Prevent developer mistakes lapply(names(environment()), function(name, envir) { delayedAssign( name, stop(sprintf("INTERNAL ERROR: %s is not declared", sQuote(name)), call. = FALSE), assign.env = envir ) }, envir = environment()) function() { mtcars |> select(mpg, cyl) |> head(3) } }) The latter would throw an error, if you actually end up using 'mpg' or 'cyl' in a non-NSE way. /Henrik On Fri, Oct 7, 2022 at 12:29 PM Martin Morgan <mtmorgan.b...@gmail.com> wrote: > > Just my two cents, but I don’t think using `globalVariables()` is a good idea > in a package – it’s too easy to say that R should ignore a variable that it > should not. > > In the context of dplyr, the alternative is to `importFrom dplyr .data` or to > use ‘standard’ evaluation, depending on circumstance > > > > mtcars |> as_tibble() |> filter(.data$mpg > 30) # .data is imported, so > > known… > # A tibble: 4 × 11 > mpg cyl disp hp drat wt qsec vs am gear carb > <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> > 1 32.4 4 78.7 66 4.08 2.2 19.5 1 1 4 1 > 2 30.4 4 75.7 52 4.93 1.62 18.5 1 1 4 2 > 3 33.9 4 71.1 65 4.22 1.84 19.9 1 1 4 1 > 4 30.4 4 95.1 113 3.77 1.51 16.9 1 1 5 2 > > mtcars |> select("mpg", "cyl") |> head(3) # `”mpg”` and `”cyl”` are > > character vectors, not symbols… > mpg cyl > Mazda RX4 21.0 6 > Mazda RX4 Wag 21.0 6 > Datsun 710 22.8 4 > > Martin > > From: Bioc-devel <bioc-devel-boun...@r-project.org> on behalf of Marcel Ramos > <marcel.ramospe...@roswellpark.org> > Date: Friday, October 7, 2022 at 3:07 PM > To: bioc-devel@r-project.org <bioc-devel@r-project.org> > Subject: Re: [Bioc-devel] Interpreting BiocCheck output > Hi Giulia, > > Thanks for sharing. > I took a look at https://github.com/calabrialab/ISAnalytics and I'm glad > you resolved the issue. > > Just a reminder, you can also use `utils::globalVariables('.')` in your > package for functions > that use `'.'` (and other symbols) as a variable, e.g. in `purrr::pmap`. > > Best regards, > > Marcel > > > On 10/6/22 4:34 AM, Giulia Pais wrote: > > > > Hi, thanks for the reply. I managed to fix the first error as it was a > > minor issue in the code, while for the second one I don’t have a > > solution since the problem appears only locally and not on Biconductor > > after the build. > > > > Just for reference the package is ISAnalytics and the BiocCheck > > version is the latest one. > > > > Thanks again, > > > > Giulia > > > > *From: *Bioc-devel <bioc-devel-boun...@r-project.org> on behalf of > > Marcel Ramos <marcel.ramospe...@roswellpark.org> > > *Date: *Wednesday, 2022October5 at 23:48 > > *To: *bioc-devel@r-project.org <bioc-devel@r-project.org> > > *Subject: *Re: [Bioc-devel] EXTERNAL: Interpreting BiocCheck output > > > > Hi Giulia, > > > > Are you using a recent version of BiocCheck? > > > > If so, check the bottom of the BiocCheck::BiocCheck(): > > > > --- > > See the <packageName>.BiocCheck folder and run > > browseVignettes(package = 'BiocCheck') > > for details. > > --- > > > > Can you provide more details, e.g., the repository of the package? > > > > Thanks. > > > > Best regards, > > > > Marcel > > > > On 10/4/22 4:44 AM, Giulia Pais wrote: > > > Hello, > > > I�m having some issues in interpreting BiocCheck outputs, maybe > > someone can tell me how to fix the issues. > > > > > > I�ve got 2 main issues that cause the check to fail after normal > > CRAN check has passed: > > > > > > 1. I get this error message > > > > > > * Checking if other packages can import this one... > > > > > > * ERROR: Packages providing 2 object(s) used in this package > > should be imported in the NAMESPACE file, otherwise packages importing > > > > > > this package may fail. > > > > > > > > > > > > However it is nowhere mentioned which packages they are and where > > those objects are instantiated so I have no clue how to solve this one > > > > > > 1. Since previous version of the package, which built and passed > > checks without issues, I�ve been using a custom *.Rmd file placed in > > inst/rmd in the vignette to recycle the same chunk of code and > > optimizing time in phase of update (I update info only once instead of > > 4 times). Even if the package passes CRAN checks, BiocCheck errors > > telling me it can�t find this Rmd file and therefore can�t evaluate > > the chunk where it is mentioned. Any suggestion on this? > > > > > > Thanks in advance > > > Giulia > > > > > > [[alternative HTML version deleted]] > > > > > > > > > _______________________________________________ > > > Bioc-devel@r-project.org mailing list > > > https://stat.ethz.ch/mailman/listinfo/bioc-devel > > <https://secure-web.cisco.com/1BHJN2d_YaqvKQMHULUaRH7QNYQJdOhBmii2EQbiAbqa5Lkeb8i3hiUIfaWofD4P7qtrIBd4DMzICkiL7nxBM9QffrsbPxL3_kbkQFAg-yuAopFfphrSrtxM2B2Z0qp-DcUG2pechJ5QE0wfC6p5VsjrRr4nhPCl3WjsqZcBETYfmUItDeY_Br3CVecmoCk5k1gglA7riYZaVCfjP1NsjpliHO07urMoNlQIYYEyGXtdcZP0VSYaKiMgyYU41JtU_ZqKBSRUTtRknaIU5cZSeS6gHT4j4gobUCm1A0EVQToHkI-c8MgdgesyootE6ZRVht1uNPHivzeujJGoWsZJUQA/https%3A%2F%2Fstat.ethz.ch%2Fmailman%2Flistinfo%2Fbioc-devel> > > > > > > This email message may contain legally privileged and/or...{{dropped:2}} > > > > _______________________________________________ > > Bioc-devel@r-project.org mailing list > > https://stat.ethz.ch/mailman/listinfo/bioc-devel > > <https://secure-web.cisco.com/1BHJN2d_YaqvKQMHULUaRH7QNYQJdOhBmii2EQbiAbqa5Lkeb8i3hiUIfaWofD4P7qtrIBd4DMzICkiL7nxBM9QffrsbPxL3_kbkQFAg-yuAopFfphrSrtxM2B2Z0qp-DcUG2pechJ5QE0wfC6p5VsjrRr4nhPCl3WjsqZcBETYfmUItDeY_Br3CVecmoCk5k1gglA7riYZaVCfjP1NsjpliHO07urMoNlQIYYEyGXtdcZP0VSYaKiMgyYU41JtU_ZqKBSRUTtRknaIU5cZSeS6gHT4j4gobUCm1A0EVQToHkI-c8MgdgesyootE6ZRVht1uNPHivzeujJGoWsZJUQA/https%3A%2F%2Fstat.ethz.ch%2Fmailman%2Flistinfo%2Fbioc-devel> > > > > This email message may contain legally privileged and/or...{{dropped:4}} > > _______________________________________________ > Bioc-devel@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/bioc-devel > > [[alternative HTML version deleted]] > > _______________________________________________ > Bioc-devel@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/bioc-devel _______________________________________________ Bioc-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/bioc-devel