为Windows创建R包-ERROR:包xxx的编译失败

时间:2010-12-01 18:00:21

标签: r

我无法在Windows上为R构建虚拟测试包。 为了测试目的,在R终端,我输入:

a=rnorm(10)
package.skeleton("pkgtest")

然后我在这个虚拟包上运行R CMD check pkgtest并得到错误,如

* using R version 2.12.0 (2010-10-15)
* using platform: i386-pc-mingw32 (32-bit)
* using session charset: ISO8859-1
* checking for file 'pkgtest/DESCRIPTION' ... OK
* checking extension type ... Package
* this is package 'pkgtest' version '1.0'
* checking package dependencies ... OK
* checking if this is a source package ... OK
* checking for executable files ... OK
* checking whether package 'pkgtest' can be installed ... ERROR Installation failed.

编辑,完整的日志文件:

* installing *source* package 'pkgtest' ...
** libs
cygwin warning:
  MS-DOS style path detected: C:/R/R-212~1.0/etc/i386/Makeconf
  Preferred POSIX equivalent is: /cygdrive/c/R/R-212~1.0/etc/i386/Makeconf
  CYGWIN environment variable option "nodosfilewarning" turns off this warning.
  Consult the user's guide for more details about POSIX paths:
    http://cygwin.com/cygwin-ug-net/using.html#using-pathnames
ERROR: compilation failed for package 'pkgtest'
`* removing 'C:/DOCUME~1/xxxx'` 

就是这样。我在数据文件夹中有一个数据a,所以它不是空的。 Rd文件实际上可以通过Rcmd rd2pdf编译为pdf,其标题不为空。

我错过了一些非常基本的错误吗?我安装了Rtools2.12。我甚至安装了包inlineRcpp并运行示例。 为了测试我的R环境设置,我下载了Rcpp源代码包并在R cmd check上执行了Rcpp,它运行良好。

2 个答案:

答案 0 :(得分:3)

是的,如果您所做的只是上面记录的步骤,那就很多了。

首先,您是否按照package.skeleton的输出要求进行操作?:

> a=rnorm(10)
> package.skeleton("pkgtest")
Creating directories ...
Creating DESCRIPTION ...
Creating Read-and-delete-me ...
Saving functions and data ...
Making help files ...
Done.
Further steps are described in './pkgtest/Read-and-delete-me'.

特别是最后一行。

你没有引用完整的CHECK日志,我得到:

$ R CMD check pkgtest
* checking for working pdflatex ... OK
* using log directory '/home/gavin/tmp/pkgtest.Rcheck'
* using R version 2.11.1 Patched (2010-08-17 r52767)
* using session charset: UTF-8
* checking for file 'pkgtest/DESCRIPTION' ... OK
* checking extension type ... Package
* this is package 'pkgtest' version '1.0'
* checking package dependencies ... OK
* checking if this is a source package ... OK
* checking for executable files ... OK
* checking whether package 'pkgtest' can be installed ... ERROR
Installation failed.
See '/home/gavin/tmp/pkgtest.Rcheck/00install.out' for details.

所以你应该去查看它提到的.out文件的内容。我在该文件中有以下内容:

$ cat /home/gavin/tmp/pkgtest.Rcheck/00install.out
* install options are ' --no-html'

* installing *source* package ‘pkgtest’ ...
** R
** data
** preparing package for lazy loading
** help
Warning: ./man/pkgtest-package.Rd:34: All text must be in a section
Warning: ./man/pkgtest-package.Rd:35: All text must be in a section
*** installing help indices
Error in Rd_info(db[[i]]) : 
  Rd files must have a non-empty \title.
See chapter 'Writing R documentation' in manual 'Writing R Extensions'.
* removing ‘/home/gavin/tmp/pkgtest.Rcheck/pkgtest’

一旦你看到包源,这是相当不言自明的。

至少需要:

> a=rnorm(10)
> package.skeleton(name = "pkgtest", list = "a")

然后您应该注意,您必须编辑Rd文件。这是一个设计功能prompt()package.skeleton()不会创建有效的Rd文件,以使包作者为其包编写最低限度的文档。

答案 1 :(得分:1)

您需要查看未显示的下一行中列出的文件中的错误。

当我尝试回溯你的步骤时,我也会收到错误:

/tmp/pkgtest$ r -e 'package.skeleton("pkgtest")'
Creating directories ...
Creating DESCRIPTION ...
Creating Read-and-delete-me ...
Saving functions and data ...
Making help files ...
Done.
Further steps are described in './pkgtest/Read-and-delete-me'.
/tmp/pkgtest$ R CMD INSTALL pkgtest/
* installing to library ‘/usr/local/lib/R/site-library’
* installing *source* package ‘pkgtest’ ...
** data
** help
Warning: /tmp/pkgtest/pkgtest/man/pkgtest-package.Rd:33: \
        All text must be in a section
*** installing help indices
Error in Rd_info(db[[i]]) : 
  Rd files must have a non-empty \title.
See chapter 'Writing R documentation' in manual 'Writing R Extensions'.
* removing ‘/usr/local/lib/R/site-library/pkgtest’
/tmp/pkgtest$ 

要让package.skeleton()有意义,你需要给它一个或多个函数,数据对象,......你没有。