On Mon, 6 Dec 2010, Sunny Srivastava wrote:
Hello Chuck:
Your idea is very interesting. I am curious to make use of your
ideas. If it
is not too much trouble, can you please share an example org file
that you
use for package development? I completely understand if you can't
share the
file.
Sunny,
I posted the vanilla version of the file at
http://famprevmed.ucsd.edu/faculty/cberry/org-mode/RpkgExample.org
It has the src blocks I use in each package.
To use it, you set up a minimal package directory structure:
myPackage/
myPackage/DESCRIPTION
myPackage/man/
myPackage/R/
say, and (optionally) put it under version control.
Or use an existing package you are already working on.
Or download one from CRAN, and untar it.
Then copy RpkgExample.org to myPackage/
(or whatever the equivalent directory is)
and you are ready to start.
FWIW, if I have a good idea of what I am doing at the outset, I will
write functions in R/*.R files and create man/*.Rd files using
prompt() and then edit them, and then get around to checking,
installing, and trying out the package from the org file.
But usually, I have only a fuzzy idea of what how to organize the
code, so I start by writing a snippet of code in an R :session src
block that sets up some objects of the sort I would want my package to
work on. I run that block. Then I might write a script in
another :session
src block to do some of the work I want the package to do, and
try it out. Once it works I wrap it into a function, and write another
:session src block to call the function. Once that works, I kill the
src block with the function in it and yank it into a fresh buffer
where it is saved as R/whatever.R. After using prompt() to make the
man/whatever.Rd and editting it, I am ready to run the package check,
install the package, restart my R session and load the package. Then I
can stitch together tests, examples, and more functions in the org
file, and test them and migrate them to the right places.
Comments welcome.