R-将“ xlsx”软件包导入我自己的软件包不起作用 [英] R - Importing 'xlsx' package to my own package doesn't work
问题描述
我正在创建自己的程序包。我在其中使用了很多现有的软件包,它们可以工作。我对 xlsx
包使用相同的过程,但是它不起作用。我的 DESCRIPTION
文件中的 Imports:
中有 xlsx
。我各自的.R文件中有 @import xlsx
。我还尝试对特定功能使用 @importFrom write.xlsx
获得相同的结果。我使用库 devtools
和 roxygen2
创建程序包。我的新程序包是生成的,但是如果我继续执行 Check
,则会发生错误:
I am creating my own package. I am using a lot of existing packages in it and they work. I am using the same procedure for the xlsx
package but it doesn't work. I have xlsx
in Imports:
in my DESCRIPTION
file. I have @import xlsx
in my respective .R file. I also tried @importFrom write.xlsx
for a particular function with the same result. I am using libraries devtools
and roxygen2
for creating the package. My new package is build, but if I proceed Check
, an error occurs:
Installation failed.
See 'C:/Work/Package/MyPackage.Rcheck/00install.out' for details.
* DONE
Status: 1 ERROR
Warning: running command '"C:/R/R-3.3.3/bin/x64/Rcmd.exe" INSTALL -l "C:/Users/Work/Package/MyPackage.Rcheck" --no-html "C:\Users\Work\Package\MyPackage.Rcheck\00_pkg_src\MyPackage"' had status 1
和
checking whether package 'MyPackage' can be installed ... ERROR
Installation failed.
See 'C:/Users/Work/Package/MyPackage.Rcheck/00install.out' for details.
R CMD check results
但是没有 .out
文件中的错误。整个文件 MyPackage.Rcheck
在检查过程中会出现一小段时间,但随后消失了。因此,我无法检查 .out
文件并发现错误。
But there is no .out
file from the error. The whole file MyPackage.Rcheck
occurs for a short time during the checking process, but then it disappears. So I am not able to check the .out
file and find an error.
我还尝试在代码中使用命令 library(xlsx)
。在这种情况下,构建和检查过程的问题较少。只有一个警告和一个注释:
I also tried to use command library(xlsx)
inside my code. In this situation the process of building and checking has less problems. There is only one warning and one note:
WARNING
'library' or 'require' call not declared from: 'xlsx'
'library' or 'require' call to 'xlsx' in package code.
Please use :: or requireNamespace() instead.
See section 'Suggested packages' in the 'Writing R Extensions' manual.
NOTE
MyFunction: no visible global function definition for 'write.xlsx'
但是我知道,如果我想将我的代码上传到CRAN,应该不会有任何警告。
But I know that if I would like to upload my code to the CRAN there should not be any warnings.
我也知道 xlsx
软件包具有两个依赖项: rJava
和 xlsxjars
。如果我将它们放在 DESCRIPTION
文件中的导入:
,并且还使用 @import
在我的.R文件中,出现相同的问题。我还尝试过使用 Depends:
获得相同的结果。
I also know that xlsx
package has two dependencies: rJava
and xlsxjars
. If I put them to Imports:
in DESCRIPTION
file and also use the @import
in my .R file the same problem appears. I also tried used Depends:
with the same results.
谢谢大家的帮助。
推荐答案
在Linux环境中反复运行而不使用Rstudio时,我仍然遇到相同的问题。
I had the same issue over and over running in a Linux environment without the usage of Rstudio.
我的问题是 @importFrom xlsx read.xlsx
,删除它并添加调用 xlsx :: read.xlsx('myFile。 xlsx',1)
在使用 read.xlsx
的代码中,然后运行 R -e devtools :: document()
正常工作。此后,我再次添加 @importFrom xlsx read.xlsx
并删除了 xlsx ::
,然后运行正常。
My issue was @importFrom xlsx read.xlsx
, removing this and adding a call xlsx::read.xlsx('myFile.xlsx', 1)
in the code where read.xlsx
is used, then running R -e "devtools::document()
works properly. After this, I've added again @importFrom xlsx read.xlsx
and removed the xlsx::
and then is working just fine.
我认为这可能与首先从设置配置有关xlsx
包,因为在执行此操作之前我从没有打过电话。
I think this could be something related to first setting up configurations from xlsx
package since before doing this I never made a call from it.
这篇关于R-将“ xlsx”软件包导入我自己的软件包不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!