I want to edit a function in the nlme package. I download the package source nlme_3.1-96.tar.gz from the link below then edit it one of the scripts inside of it. From this stage how can I turn it into a package that I can use in R? http://cran.r-project.org/web/packages/nlme/index.html -- View this message in context: http://r.789695.n4.nabble.com/Turning-a-source-into-a-Package-tp2318796p2318796.html Sent from the R help mailing list archive at Nabble.com.
On 08/10/2010 02:51 AM, JH wrote:> > I want to edit a function in the nlme package. I download the package source > nlme_3.1-96.tar.gz from the link below then edit it one of the scripts > inside of it. From this stage how can I turn it into a package that I can > use in R? > > http://cran.r-project.org/web/packages/nlme/index.htmlHi JH, The problem I have encountered with this is that installed packages often do not have all the required directories and the source code for checking and building. With a small package, you can get the source code for all the functions by sinking the output produced by invoking each function name without arguments to a file in the R subdirectory (copy the whole installed package directory to another location first): sink("anova.lme.R") cat("anova.lme<-") anova.lme sink() but this is only practical for small packages. You would also have to back translate the HTML help files to Rd format and place these in the man directory, again a considerable task for a package like nlme. Your best bet for something like this is to load the library: library(nlme) and then source the modified code: source("anova.lme.R") or whatever function you have modified. You can even write a function to do this: my.library(x,newfile) { library(x) source(newfile) } my.library("nlme","anova.lme.R") Jim
On 08/09/2010 06:51 PM, JH wrote:> I want to edit a function in the nlme package. I download the package source > nlme_3.1-96.tar.gz from the link below then edit it one of the scripts > inside of it. From this stage how can I turn it into a package that I can > use in R? > > http://cran.r-project.org/web/packages/nlme/index.html >Building R packages under Windows (which I assume you are using, but you don't specify) can be done by looking at the instructions at: http://www.murdoch-sutherland.com/Rtools/ But to be true, loading the library and than sourcing the one function you changed, like Jim Lemon suggested, is a better option. regards, Paul -- Drs. Paul Hiemstra Department of Physical Geography Faculty of Geosciences University of Utrecht Heidelberglaan 2 P.O. Box 80.115 3508 TC Utrecht Phone: +3130 253 5773 http://intamap.geo.uu.nl/~paul http://nl.linkedin.com/pub/paul-hiemstra/20/30b/770