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

Hi 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

______________________________________________
R-help@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.

Reply via email to