大家好,
问题描述:
我最近想要向CRAN提交一个我个人编写的R包,这是我初次进行R包提交,但是提交的时候遇到了些问题,R包提交通过自动检查后,在CRAN人工审核,人工审核人员回复如下:
Please ensure that your functions do not write by default or in your
examples/vignettes/tests in the user's home filespace (including the
package directory and getwd()). That is not allowed by CRAN policies.
In your examples/vignettes/tests you can write to tempdir().
Please do not modify the global environment (e.g. by using <<-) in your
functions.
This is not allowed by the CRAN policies.
Please fix and resubmit.
但我在我的代码中找不到它所提到的两个问题(“不要修改全局环境(例如<<-)”、“不要在本地目录下创建文件”),大家可以帮我找一下一下没问题所在么?
我的R包的代码github地址:
https://github.com/s0521/guiplot
我的一些思路:
对于问题“不要在本地目录下创建文件”,我认为我代码中唯一可能相关的是,我在包的测试用例里撰写了这样一个测试用例
#' \donttest{
#' guiplot(PK,out_dir=getwb())
#' }
在其中推荐将文件输出目录设定为当前工作目录“getwb()”,但程序本身在不设定目录的情况下我使用了临时目录if(is.null(out_dir)) out_dir<-tempdir()
对于问题(“不要修改全局环境(例如<<-)”,我确实在我的R包中用到了"<<-"符号,该符号用于为我所定义的3个"Reference Class"内部,用于类的方法为类的字段赋值,我没有找到其他可以代替"<<-"符号为字段赋值的方法,而且我认为在"Reference Class"内部使用"<<-"符号,他并不会影响到全局加环境。