[R] Modifying a package name / Build from sources (rpart)

Marc Schwartz marc_schwartz at me.com
Thu Feb 10 20:43:20 CET 2011


On Feb 10, 2011, at 12:13 PM, Ben Bolker wrote:

> Simon Knos <simon_mailing <at> quantentunnel.de> writes:
> 
>> Upfront: I am not sure if this is the right place to ask this question even
>> after reading through the FAQ, so apologies if I should have directed the
>> question elsewhere.
> 
>  I appreciate your confusion.  I think this might be slightly more
> appropriate for r-devel, but it's a judgment call.
> 
>> My problem as follows: I need a modified version of some existing R package.
>> I am well able to make the modifications in the C code of the package and
>> can build it by R CMD. However, I would like to install and load the package
>> differently, i.e., instead of library(packageorig) I would like to load it
>> by library(packagemod) such that the functions names provided by the package
>> remain identical but the library / packagename is different.
>> 
>> More specifically, I need a different cross-validtion scheme in the package
>> rpart.
>> 
>> Which parts of the sources do I need to adapt? Can you point me to
>> some resources where this kind of questions is answered?
> 
>  I think that if you simply modify the "Package:" entry in the
> DESCRIPTION file that will do the trick.  It might be a good idea
> to modify the version/author/maintainer lines as well to avoid future
> confusion.
> 
>  See the R "Installation and Administration" manual.


One other point I might add to Ben's comments, which is that rpart has a NAMESPACE file, the contents of which you will want to modify in your new new package so that it references it and not rpart. Since rpart is a recommended package, it will be installed by default with R.

Modifying the NAMESPACE file would avoid potential function calling conflicts between the packages under various circumstances. It would also allow you to run functions from both by using rpart::FunctionName versus YourPackage::FunctionName, where FunctionName is the same.

You might want to review The Writing R Extensions manual for more information.

HTH,

Marc Schwartz



More information about the R-help mailing list