On 10/26/2009 10:29 AM, Peng Yu wrote:
I am reading Section 5 and 6 of
http://cran.r-project.org/doc/contrib/Leisch-CreatingPackages.pdf

It seems that I have to do the following two steps in order to make an
R package. But when I am testing these package, these two steps will
run many times, which may take a lot of time. So when I still develop
the package, shall I always source('linmod.R') to test it. Once the
code in linmod.R is finalized, then I run the following two steps?

I'm wondering what people usually do when developing packages.


1. Run the following command in R to create the package
package.skeleton(name="linmod", code_files="linmod.R")

2. Run the following command in shell to install
R CMD INSTALL -l /path/to/library linmod

You only do step 1 once, and you missed step 1.5: edit the files, which comes before step 2.

I usually cycle between steps 1.5 and 2 multiple times. Sometimes I will not repeat step 2, I'll put together a small script that includes

source('linmod.R')
environment(somefunction) <- environment(linmod::somefunction)

and source that instead. The second line makes somefunction look for functions in the namespace of the package; it's only useful if my edits only affect one function, and the functions in the package never call it: so usually I do the full install.

Duncan Murdoch

______________________________________________
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