Tobias Setz
2014-Sep-18 15:20 UTC
[Rd] "no visible global function definition" using R-Devel check utility
Hello All If I check the package fAssets using R-3.1.1 (2014-07-10 under Windows) I don't get any notes. If I do the same using R-Devel (2014-09-17 r66626 under Windows) I get the following note: . assetsMeanCov: no visible binding for global variable 'scaleTau2' . I'll try to explain why with a minimal example. Let's have a look at the following function: assetsMeanCov <- function(x, method = c("cov", "MCD", "OGK"), alpha = 1/2, sigmamu = scaleTau2, ...) { if (method == "cov") {cov(x, ...)} if (method == " MCD") {robustbase::covMcd(x, alpha = alpha, ...)} if (method == " OGK") {robustbase::covOGK(x, sigmamu substitute(sigmamu), ...)} } where robustbase is mentioned under "Suggests:" within the DESCRIPTION file. This since the function is also usable without having that package available. R check is now complaining since it cannot find the function 'scaleTau2' defined within the packages namespace or any imported namespaces. Which is true; since this function is defined within the robustbase package whose namespace is not imported. Note that: 1) The function works like that if the package is built. No error or warning if method="OGK" is used. 2) By "promoting" the package robustbase to "Imports:" within the DESCRIPTION file and importing that function within the NAMESPACE file the note would be gone. 3) Using "sigmamu = robustbase::scaleTau2" would solve the "problem" as well. I am not very much in favour to import the robustbase package since it is not necessarily needed. Also I don't know if using the "::" operator within the functions arguments list is a good concept. Also since the code works without having that. Therefore I am wondering if this new behaviour within R-Devel (compared to R-3.1.1) is intentionally and if yes; what would be best practice for such a setup? Many thanks for your help and time!! Tobias> sessionInfo()R version 3.1.1 (2014-07-10) Platform: x86_64-w64-mingw32/x64 (64-bit)