[R] What is the most efficient practice to develop an R package?
edd at debian.org
Mon Oct 26 17:22:29 CET 2009
On 26 October 2009 at 07:57, Martin Morgan wrote:
| 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")
| Do this once, to get a skeleton. Then edit the R source etc in the
| created package.
| > 2. Run the following command in shell to install
| > R CMD INSTALL -l /path/to/library linmod
| see R CMD INSTALL --help and use options that minimize the amount of
| non-essential work, e.g., no vignettes or documentation until that is
| the focus of your development, or --libs-only if you are working on C
| code. Use --clean to avoid stale package components. Develop individual
| functions interactively, but write a script
| so that R -f myscript.R allows you to easily load your package and test
| specific functionality in a clean R session.
With littler you can do without the one-off script as
$ r -lMyPackage -e'print(someFunction())'
runs both commands you would have put into script. Hence, I often do
$ R CMD INSTALL MyPackage/ && r -lMyPackage -e'print(someFunction())'
Three out of two people have difficulties with fractions.
More information about the R-help