[R] Convert windows package to Linux source package

Renaud Gaujoux renaud at mancala.cbio.uct.ac.za
Fri Oct 31 08:06:34 CET 2008


Indeed in the case of a lazy-loaded package it looks a bit tricky, but 
it should still be possible, as I guess one can access the source code 
of any function defined in a package, once loaded (am I wrong?).

When no lazy-load takes place then it is actually quite straight forward 
as you said Duncan:
- I looked into the merged Rd file, and the functions documentation 
appear embedded between as follows:
% --- Source file: function-name.Rd
...
...
\eof

So with some shell scripting (csplit, sed, ...) I succeeded in separate 
the single file into separate Rd files, named after the functions' names.
- the source files can be generated using package.skeleton on the R 
source files (remember no lazy-load, so plain and complete source code 
is directly available)
- then replace the generic Rd files generated by package.skeleton by the 
Rd files obtained from the merged Rd file.
- copy the original DESCRIPTION file into the source package directory, 
removing the 'Build' section.

In theory this works well, except if:

- the window packages Rd file contains error (!): I couldn't believe it 
but some of the Rd definitions where wrong (missing closing bracket, 
invalid tags (reference instead of references), invalid keywords, ...). 
Isn't it mandatory to have valid Rd files to be able to build a package 
with R CMD build?
- the package's dependencies are not defined in the original DESCRIPTION 
file. Isn't it also mandatory to specify if the package depends on other 
packages ? (because R CMD check can effectively detect the discrepancy 
between the field  DESCRIPTION:Dependencies and what is directly 
required by the package...)



Prof Brian Ripley wrote:
> On Thu, 30 Oct 2008, Duncan Murdoch wrote:
>
>> On 10/30/2008 10:50 AM, Renaud Gaujoux wrote:
>>> Hi,
>>>
>>> is there a simple way, I mean a utility that converts a windows 
>>> package (.zip file) to a Linux source package (tar.gz or even simply 
>>> extract the source code and Rd files needed to run successfully a R 
>>> CMD check).
>>> The windows package doesn't have any external lib, C code, etc..., 
>>> just plain R code, so in theory it is quite straight forward 
>>> (extract the code from the functions, and re-separate the Rd files 
>>> from the man directory.
>>>
>>> Any idea?
>>
>> No, no such utility exists as far as I know.  But as you say, it 
>> should be relatively straightforward to write one:  the Rd files are 
>> concatenated and compressed into man/pkg.Rd.gz, and the R files are 
>> concatenated into R/pkg.
>
> Not if lazy-loading is used (and it normally is).  But what really is 
> wrong with Roger Koenker's suggestion: 'unzip -a' the .zip into a 
> library directory?  It will most likely work (the reverse does: zip up 
> on Linux, unzip on Windows).
>
>> You just need to watch out for comments in the files that will be 
>> mistaken for separators.
>
> I think that is safe enough in Rd files, as we process the 
> concatenated versions.
>
>> Duncan Murdoch
>>
>> ______________________________________________
>> R-help at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide 
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>



More information about the R-help mailing list