Avoiding a note about `assign` when checking a package (where` do.call` cannot be used)

I use assignto get around the problems in the package car, as suggested by the authors of the package . This gives me Notewhen checking pages with devtools::check.

The standard workaround for this is to use do.call. However, as far as I can tell, this only works when using functions that do not extract data from the environment (i.e., which allow you to pass data as arguments), which is not my situation.

Example of where i use assignment

Please note that the residualPlotsextracts .estimation.dataand .formulaof the environment.

assign(".estimation.data", model$estimation.data, envir=.GlobalEnv)
assign(".formula", model$formula, envir=.GlobalEnv)
t <- residualPlots(model$original)
remove(".formula", envir=.GlobalEnv)
remove(".estimation.data", envir=.GlobalEnv)

Replication Instructions

- . , , .  1. : https://github.com/Displayr/flipRegression  2. ( RStudio)  3. devtools::check(cleanup = FALSE, args = c('--no-build-vignettes','--no-manual','--no-tests'))

checking R code for possible problems ... NOTE
Found the following assignments to the global environment:
File 'flipRegression/R/regressiondiagnostics.R':
   assign(".estimation.data", model$estimation.data, envir = .GlobalEnv)
   assign(".formula", model$formula, envir = .GlobalEnv)
   assign(".estimation.data", .estimation.data, envir = .GlobalEnv)
   assign(".formula", model$formula, envir = .GlobalEnv)
   assign(".design", model$design, envir = .GlobalEnv)
   assign(".estimation.data", x$estimation.data, envir = .GlobalEnv)
   assign(".formula", formula(model), envir = .GlobalEnv)
 R CMD check results
 0 errors | 0 warnings | 1 note 
 Warning message:
 `cleanup` is deprecated 
 R CMD check succeeded
+4

Source: https://habr.com/ru/post/1669658/


All Articles