Search code examples
rpackagecran

checking R code for possible problems ... NOTE


After run devtools::check(cran=TRUE)

This is the warning message I get. I tried to add those "imports" into NAMESPACE directly. But it doesn't work as NAMESPACE is generated by roxygen2 so that I can't edit by hand. However, how can I edit those extra imports? I really wonder where should I start fixing those warnings. Thanks for helping!!!

checking R code for possible problems ... NOTE
  SeasonalityTest: no visible global function definition for 'acf'
  Smoothing_ts2: no visible global function definition for
    'BoxCox.lambda'
  Smoothing_ts2: no visible global function definition for 'BoxCox'
  Smoothing_ts2: no visible global function definition for 'InvBoxCox'
  Smoothing_ts2: no visible global function definition for 'loess'
  diss.cort: no visible global function definition for 'dist'
  generate_ts_with_target_ts: no visible global function definition for
    'nsdiffs'
  generate_ts_with_target_ts: no visible global function definition for
    'InvBoxCox'
  generate_ts_with_target_ts: no visible global function definition for
    'BoxCox'
  pars2x1: no visible global function definition for 'ndiffs'
  pars2x1: no visible global function definition for 'nsdiffs'
  scalets01: no visible global function definition for 'tsp<-'
  scalets01: no visible global function definition for 'tsp'
  Undefined global functions or variables:
    BoxCox BoxCox.lambda InvBoxCox acf dist loess ndiffs nsdiffs tsp
    tsp<-
  Consider adding
    importFrom("stats", "acf", "dist", "loess", "tsp", "tsp<-")
  to your NAMESPACE file.

Solution

  • You can specify the packages to import in each function definition using the @import or @importFrom keywords in the Roxygen description:

    #' Title
    #'
    #' @return 
    #' @importFrom stats acf dist loess tsp tsp<-
    #' @export
    #'
    #' @examples
    foo <- function() {} 
    

    NAMESPACE will be automatically modified after running devtools::document(), see R Packages : Imports.
    You have to modify the DESCRIPTION file manually.