R devtools :: check ЛИЦЕНЗИЯ не упоминается и другие проблемы в файле описания - PullRequest
1 голос
/ 12 мая 2019

Начав создавать пакет, я собрал несколько функций, а затем запустил devtools :: check (), чтобы убедиться, что я на правильном пути. Ниже я копирую весь вывод команды devtools::check(). Есть две заметки, которые меня удивляют. Я надеюсь, что, очистив эти две вещи, другие вещи легче исправить, поэтому я начну с них. Я не пытаюсь решить все проблемы из проверки, просто пытаюсь понять эти два. Первое:

Файл LICENSE не указан в файле DESCRIPTION

Другой идет после

проверка кода R на возможные проблемы (3.7с)

где много сообщений " нет видимого определения глобальной функции ", несмотря на то, что эти функции находятся в пакетах, которые импортируются в файл DESCRIPTION.

Ниже приведен файл ОПИСАНИЕ. Весь воспроизводимый код можно найти в https://github.com/rexmacey/factorModel. После этого выводится команда devtools :: check.

Package: factorModel
Title: Factor Model Creation and Evaluation
Version: 0.0.0.9000
Authors@R: person("Rex", "Macey", email = "rex@macey.us", role = c("aut", "cre"))
Description: Creates and tests factor models.
Depends: R (>= 3.5.0)
License: GPL-2
Encoding: UTF-8
LazyData: true
Imports:
  dplyr,
  knitr,
  lubridate,
  ggplot2,
  reshape2,
  tidyquant
Suggests:
    utils,
    testthat
VignetteBuilder:
  utils
RoxygenNote: 6.1.1

Вывод из devtools :: check

> check()
Updating factorModel documentation
Writing NAMESPACE
Loading factorModel
Writing NAMESPACE
-- Building -------------------------------------------------------------- factorModel --
Setting env vars:
* CFLAGS    : -Wall -pedantic
* CXXFLAGS  : -Wall -pedantic
* CXX11FLAGS: -Wall -pedantic
-----------------------------------------------------------------------------------------
√  checking for file 'C:\Users\Rex\Google Drive\RedTortoise\Research - RT\factorModel/DESCRIPTION' (449ms)
-  preparing 'factorModel': (441ms)
√  checking DESCRIPTION meta-information ... 
-  excluding invalid files
   Subdirectory 'R' contains invalid file names:
     'desktop.ini'
   Subdirectory 'man' contains invalid file names:
     'desktop.ini'
-  checking for LF line-endings in source and make files and shell scripts
-  checking for empty or unneeded directories
-  looking to see if a 'data/datalist' file should be added
-  building 'factorModel_0.0.0.9000.tar.gz'

-- Checking -------------------------------------------------------------- factorModel --
Setting env vars:
* _R_CHECK_CRAN_INCOMING_REMOTE_: FALSE
* _R_CHECK_CRAN_INCOMING_       : FALSE
* _R_CHECK_FORCE_SUGGESTS_      : FALSE
-- R CMD check --------------------------------------------------------------------------
-  using log directory 'C:/Users/Rex/AppData/Local/Temp/Rtmp4ig3Oj/factorModel.Rcheck' (400ms)
-  using R version 3.5.1 (2018-07-02)
-  using platform: x86_64-w64-mingw32 (64-bit)
-  using session charset: ISO8859-1
-  using options '--no-manual --as-cran'
√  checking for file 'factorModel/DESCRIPTION'
-  this is package 'factorModel' version '0.0.0.9000'
-  package encoding: UTF-8
√  checking package namespace information
√  checking package dependencies (952ms)
√  checking if this is a source package ...
√  checking if there is a namespace
√  checking for .dll and .exe files
√  checking for hidden files and directories ... 
√  checking for portable file names ... 
√  checking whether package 'factorModel' can be installed (5.1s)
√  checking package directory (767ms)
√  checking DESCRIPTION meta-information (644ms)
N  checking top-level files
   File
     LICENSE
   is not mentioned in the DESCRIPTION file.
√  checking for left-over files ...
√  checking index information
√  checking package subdirectories ... 
√  checking R files for non-ASCII characters ... 
√  checking R files for syntax errors ... 
√  checking whether the package can be loaded ... 
√  checking whether the package can be loaded with stated dependencies ... 
√  checking whether the package can be unloaded cleanly ... 
√  checking whether the namespace can be loaded with stated dependencies ... 
√  checking whether the namespace can be unloaded cleanly (521ms)
√  checking loading without being on the library search path (697ms)
√  checking dependencies in R code ... 
√  checking S3 generic/method consistency (609ms)
√  checking replacement functions ... 
√  checking foreign function calls ... 
N  checking R code for possible problems (3.6s)
   AddFactor: no visible global function definition for '%>%'
   AddFactor: no visible global function definition for 'filter'
   GetFundReturns: no visible global function definition for '%>%'
   GetFundReturns: no visible global function definition for 'tq_get'
   GetFundReturns: no visible global function definition for '%m+%'
   GetFundReturns: no visible global function definition for 'days'
   GetFundReturns: no visible global function definition for 'group_by'
   GetFundReturns: no visible binding for global variable 'symbol'
   GetFundReturns: no visible global function definition for
     'tq_transmute'
   GetFundReturns: no visible binding for global variable 'adjusted'
   GetFundReturns: no visible binding for global variable 'periodReturn'
   GetFundReturns: no visible global function definition for 'filter'
   plot_corr: no visible global function definition for 'cor'
   plot_corr: no visible global function definition for 'melt'
   plot_corr: no visible global function definition for 'ggplot'
   plot_corr: no visible global function definition for 'aes'
   plot_corr: no visible binding for global variable 'Var2'
   plot_corr: no visible binding for global variable 'Var1'
   plot_corr: no visible binding for global variable 'value'
   plot_corr: no visible global function definition for 'geom_tile'
   plot_corr: no visible global function definition for
     'scale_fill_gradient2'
   plot_corr: no visible global function definition for 'theme_minimal'
   plot_corr: no visible global function definition for 'theme'
   plot_corr: no visible global function definition for 'element_text'
   plot_corr: no visible global function definition for 'coord_fixed'
   plot_corr: no visible global function definition for 'xlab'
   plot_corr: no visible global function definition for 'ylab'
   plot_corr: no visible global function definition for 'geom_text'
   plot_corr: no visible global function definition for 'element_blank'
   plot_corr: no visible global function definition for 'guides'
   plot_corr: no visible global function definition for 'guide_colorbar'
   Undefined global functions or variables:
     %>% %m+% Var1 Var2 adjusted aes coord_fixed cor days element_blank
     element_text filter geom_text geom_tile ggplot group_by
     guide_colorbar guides melt periodReturn scale_fill_gradient2 symbol
     theme theme_minimal tq_get tq_transmute value xlab ylab
   Consider adding
     importFrom("stats", "cor", "filter")
   to your NAMESPACE file.

   Found the following calls to data() loading into the global environment:
   File 'factorModel/R/loadLibraries.r':
     data(factorReturns)
     data("factorReturns.US")
     data(factorReturns.Intl)
     data(factorReturns.EM)
     data("factorGroups")
   See section 'Good practice' in '?data'.
√  checking Rd files ... 
√  checking Rd metadata ... 
√  checking Rd line widths ... 
√  checking Rd cross-references ... 
√  checking for missing documentation entries ... 
√  checking for code/documentation mismatches (730ms)
√  checking Rd \usage sections (816ms)
√  checking Rd contents ... 
√  checking for unstated dependencies in examples ... 
W  checking contents of 'data' directory ... 
   Files not of a type allowed in a 'data' directory:
     'desktop.ini'
   Please use e.g. 'inst/extdata' for non-R data files
√  checking data for non-ASCII characters ... 
√  checking data for ASCII and uncompressed saves ... 
E  checking examples (653ms)
   Running examples in 'factorModel-Ex.R' failed
   The error most likely occurred in:

   > base::assign(".ptime", proc.time(), pos = "CheckExEnv")
   > ### Name: AddFactor
   > ### Title: Add a Factor
   > ### Aliases: AddFactor
   > 
   > ### ** Examples
   > 
   > AddFactor(factorReturns=factorReturns.US, newFactorReturns=newFactorReturns, calcExcess=TRUE)
   Error in FindMaxCommonDateRange(factorReturns$date, newFactorReturns$date) : 
     object 'newFactorReturns' not found
   Calls: AddFactor -> FindMaxCommonDateRange
   Execution halted
√  checking for unstated dependencies in 'tests' ... 
-  checking tests ...
E  Running 'testthat.R'
   Running the tests in 'tests/testthat.R' failed.
   Last 13 lines of output:
     5: eval(quote(`_fseq`(`_lhs`)), env, env)
     6: `_fseq`(`_lhs`)
     7: freduce(value, `_function_list`)
     8: withVisible(function_list[[k]](value))
     9: function_list[[k]](value)
     10: filter(., date >= dateRange["start"] & date <= dateRange["end"])
     11: Ops.Date(date, dateRange["start"])
     12: NextMethod(.Generic)

     == testthat results  ===========================================================
     OK: 0 SKIPPED: 0 FAILED: 1
     1. Error: AddFactor adds a column,  restricts dates (@test_AddFactor.r#9) 

     Error: testthat unit tests failed
     Execution halted

   See
     'C:/Users/Rex/AppData/Local/Temp/Rtmp4ig3Oj/factorModel.Rcheck/00check.log'
   for details.

-- R CMD check results -------------------------------------- factorModel 0.0.0.9000 ----
Duration: 22.1s

> checking examples ... ERROR
  Running examples in 'factorModel-Ex.R' failed
  The error most likely occurred in:

  > base::assign(".ptime", proc.time(), pos = "CheckExEnv")
  > ### Name: AddFactor
  > ### Title: Add a Factor
  > ### Aliases: AddFactor
  > 
  > ### ** Examples
  > 
  > AddFactor(factorReturns=factorReturns.US, newFactorReturns=newFactorReturns, calcExcess=TRUE)
  Error in FindMaxCommonDateRange(factorReturns$date, newFactorReturns$date) : 
    object 'newFactorReturns' not found
  Calls: AddFactor -> FindMaxCommonDateRange
  Execution halted

> checking tests ...
  See below...

> checking contents of 'data' directory ... WARNING
  Files not of a type allowed in a 'data' directory:
    'desktop.ini'
  Please use e.g. 'inst/extdata' for non-R data files

> checking top-level files ... NOTE
  File
    LICENSE
  is not mentioned in the DESCRIPTION file.

> checking R code for possible problems ... NOTE
  AddFactor: no visible global function definition for '%>%'
  AddFactor: no visible global function definition for 'filter'
  GetFundReturns: no visible global function definition for '%>%'
  GetFundReturns: no visible global function definition for 'tq_get'
  GetFundReturns: no visible global function definition for '%m+%'
  GetFundReturns: no visible global function definition for 'days'
  GetFundReturns: no visible global function definition for 'group_by'
  GetFundReturns: no visible binding for global variable 'symbol'
  GetFundReturns: no visible global function definition for
    'tq_transmute'
  GetFundReturns: no visible binding for global variable 'adjusted'
  GetFundReturns: no visible binding for global variable 'periodReturn'
  GetFundReturns: no visible global function definition for 'filter'
  plot_corr: no visible global function definition for 'cor'
  plot_corr: no visible global function definition for 'melt'
  plot_corr: no visible global function definition for 'ggplot'
  plot_corr: no visible global function definition for 'aes'
  plot_corr: no visible binding for global variable 'Var2'
  plot_corr: no visible binding for global variable 'Var1'
  plot_corr: no visible binding for global variable 'value'
  plot_corr: no visible global function definition for 'geom_tile'
  plot_corr: no visible global function definition for
    'scale_fill_gradient2'
  plot_corr: no visible global function definition for 'theme_minimal'
  plot_corr: no visible global function definition for 'theme'
  plot_corr: no visible global function definition for 'element_text'
  plot_corr: no visible global function definition for 'coord_fixed'
  plot_corr: no visible global function definition for 'xlab'
  plot_corr: no visible global function definition for 'ylab'
  plot_corr: no visible global function definition for 'geom_text'
  plot_corr: no visible global function definition for 'element_blank'
  plot_corr: no visible global function definition for 'guides'
  plot_corr: no visible global function definition for 'guide_colorbar'
  Undefined global functions or variables:
    %>% %m+% Var1 Var2 adjusted aes coord_fixed cor days element_blank
    element_text filter geom_text geom_tile ggplot group_by
    guide_colorbar guides melt periodReturn scale_fill_gradient2 symbol
    theme theme_minimal tq_get tq_transmute value xlab ylab
  Consider adding
    importFrom("stats", "cor", "filter")
  to your NAMESPACE file.

  Found the following calls to data() loading into the global environment:
  File 'factorModel/R/loadLibraries.r':
    data(factorReturns)
    data("factorReturns.US")
    data(factorReturns.Intl)
    data(factorReturns.EM)
    data("factorGroups")
  See section 'Good practice' in '?data'.

-- Test failures ---------------------------------------------------------- testthat ----

> library(testthat)
> library(factorModel)
> 
> test_check("factorModel")
-- 1. Error: AddFactor adds a column,  restricts dates (@test_AddFactor.r#9)  --
comparison (5) is possible only for atomic and list types
1: AddFactor(fr1, fr2, TRUE) at testthat/test_AddFactor.r:9
2: factorReturns %>% filter(date >= dateRange["start"] & date <= dateRange["end"])
3: withVisible(eval(quote(`_fseq`(`_lhs`)), env, env))
4: eval(quote(`_fseq`(`_lhs`)), env, env)
5: eval(quote(`_fseq`(`_lhs`)), env, env)
6: `_fseq`(`_lhs`)
7: freduce(value, `_function_list`)
8: withVisible(function_list[[k]](value))
9: function_list[[k]](value)
10: filter(., date >= dateRange["start"] & date <= dateRange["end"])
11: Ops.Date(date, dateRange["start"])
12: NextMethod(.Generic)

== testthat results  ===========================================================
OK: 0 SKIPPED: 0 FAILED: 1
1. Error: AddFactor adds a column,  restricts dates (@test_AddFactor.r#9) 

Error: testthat unit tests failed
Execution halted

2 errors x | 1 warning x | 2 notes x

1 Ответ

1 голос
/ 13 мая 2019

Вы определенно хотите проверить книгу R пакетов Хэдли Уикхем. У него также есть глава о Проверка .

Чтобы избавиться от ПРИМЕЧАНИЕ из-за "ЛИЦЕНЗИИ не упоминается", вы должны изменить License: GPL-3 на License: GPL-3 + file LICENSE (см. Также http://r -pkgs.had.co.nz / description.html #). лицензия ). Или вы должны удалить файл LICENSE.

Что касается no visible global function definition, вам нужно определить, откуда приходят ваши функции. Они либо определены вами в вашей упаковке. Или их нужно импортировать. Чтобы импортировать, скажем, group_by() из dplyr, вам нужно сделать следующее (см. Также http://r -pkgs.had.co.nz / namespace.html # import ):

  1. Список dplyr в файле DESCRIPTION (например, в разделе Imports)

  2. Импорт group_by() по

    • замена group_by() на dplyr::group_by() или
    • импорт функции с использованием @importFrom dplyr group_by.

Это наиболее важные параметры, о которых вы можете прочитать в http://r -pkgs.had.co.nz / namespace.html .

...