gpt4 book ai didi

R devtools::check LICENSE 未提及以及描述文件中的其他问题

转载 作者:行者123 更新时间:2023-12-01 21:24:45 25 4
gpt4 key购买 nike

开始创建一个包,我构建了一些函数,然后运行 ​​devtools::check() 以确保我步入正轨。下面我复制了 devtools::check() 命令的整个输出。有两个注释让我感到惊讶。我希望通过清理这两件事,其他事情变得更容易修复,所以我从它们开始。我并不是想解决检查中的所有问题,只是想理解这两个问题。第一个是:

File LICENSE is not mentioned in the DESCRIPTION file

另一个在后面

checking R code for possible problems (3.7s)

其中有许多消息“没有可见的全局函数定义”,尽管这些函数位于在描述文件中导入的包中。

以下是描述文件。完整的可重现代码可以在 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

最佳答案

你一定想看看这本书R packages作者:哈德利·威克姆。他还有一章关于 Checking .

由于“未提及许可证”而去掉注释,您应该将 License: GPL-3 更改为 License: GPL-3 + file LICENSE (另请参见 http://r-pkgs.had.co.nz/description.html#license )。或者您应该删除文件 LICENSE。

关于没有可见的全局函数定义,您需要定义函数的来源。它们要么由您在包中定义。或者它们需要进口。例如,要从 dplyr 导入 group_by(),您需要执行以下操作(另请参阅 http://r-pkgs.had.co.nz/namespace.html#imports ):

  1. 在描述文件中列出 dplyr(例如,在“导入”下)

  2. 通过任一方式导入 group_by()

  • group_by() 替换为 dplyr::group_by(),或者
  • 使用 @importFrom dplyr group_by 导入函数。

这些是最重要的选项,您可以在 http://r-pkgs.had.co.nz/namespace.html 中阅读。 .

关于R devtools::check LICENSE 未提及以及描述文件中的其他问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56102225/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com