Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

build R pacakge for windows -ERROR: compilation failed for package xxx

Tags:

r

I am having trouble to build a dummy testing package for R on windows. for testing purpose,in R terminal, I input:

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

then I run R CMD check pkgtest on this dummy package and got error like

* 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.

EDIT,The full log file:

* 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'` 

That is all. I have a data a in the data folder, so it is not empty. The Rd file can actually compile to pdf by Rcmd rd2pdf, its title is not empty.

did I missing something very basic for this error? I Have Rtools2.12 installed. I even have package inline and Rcpp intalled and running examples fine. To test my R environment setup, I downloaded Rcpp source package and did a R cmd check on Rcpp, it went fine.

like image 816
learnrpackage Avatar asked Oct 14 '22 20:10

learnrpackage


2 Answers

Yes, a lot if all you did were the steps documented above.

Firstly, did you do as the output from package.skeleton asks you to?:

> 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'.

In particular the last line.

You don't quote the full CHECK log, I get:

$ 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.

So you should go and check the contents of the .out file it mentions. I have the following in that file:

$ 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’

Which is fairly self-explanatory, once you look at the package source.

You needed at least:

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

And then you should note that you do have to edit the Rd files. It is a design feature that prompt() and package.skeleton() do not create valid Rd files to get package authors to write the minimum documentation for their packages.

like image 92
Gavin Simpson Avatar answered Oct 23 '22 09:10

Gavin Simpson


You need to look at the errors in the file listed in the next line you didn't show.

When I try to retrace your steps, I also get an error:

/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$ 

For package.skeleton() to be meaningful, you need to give it one or more functions, data objects, ... which you did not.

like image 27
Dirk Eddelbuettel Avatar answered Oct 23 '22 09:10

Dirk Eddelbuettel