[R] First R Package --- Advice?

Yihui Xie xie at yihui.name
Wed Feb 6 03:53:05 CET 2013


My short answer is to watch this video by Jeffrey Horner
http://youtu.be/ScV7XXlBZww and learn roxygen2.

And the long answer is to read the manual which has everything you
need: http://cran.r-project.org/doc/manuals/r-release/R-exts.html

Regards,
Yihui
--
Yihui Xie <xieyihui at gmail.com>
Phone: 515-294-2465 Web: http://yihui.name
Department of Statistics, Iowa State University
2215 Snedecor Hall, Ames, IA


On Tue, Feb 5, 2013 at 6:43 PM, ivo welch <ivo.welch at anderson.ucla.edu> wrote:
> Dear R experts---
>
> after many years, I am planning to give in and write my first R
> package.  I want to combine my collection of collected useful utility
> routines.
>
> as my guide, I am planning to use Friedrich Leisch's "Creating R
> Packages: A Tutorial" from Sep 2009.  Is there a newer or better
> tutorial?  this one is 4 years old.
>
> I also plan on one change---given that the package.skeleton() function
> writes all the individual man[ual] functions, I am thinking it would
> be a good idea to put the doc and the R code together in the same
> file, one for each function.  Interestingly enough, the code is by
> default in the \examples{} section, so I am thinking of writing a perl
> program that takes every .Rd file and writes the function into the R/
> directory, overwriting anything else that is already there.  this way,
> I maintain only one file for each function, and the docs and code are
> together.  sort of like knuth's literate programming and the
> numerical-recipees approach to keeping each function in its own file
> with equal name.
>
> I believe my "try-out and debug cycle" will then be
>
>    $ cd iaw  ## the package name and top directory is iaw
>    $ perl weaveall.pl   ## extract all man/*.Rd files code examples
> and place them in R/
>    $ R CMD INSTALL iaw
>    $ R CMD check iaw
>
> good idea?  bad idea?  common?  uncommon?
>
> I do not understand the namespace mechanism yet.  I understand the
> NAMESPACE file, and I think this lists the routines that become
> visible when a later program of mine contains 'library(iaw)'.  I think
> I want to explicitly declare what packages are actually imported.
> ?importIntoEnv tells me that it is not intended to be used.  how can
> another program declare exactly what functions it wants to import?
> (frankly, I would love to turn all default autovivification off in my
> program, but that's not possible.)
>
> /iaw
> ----
> Ivo Welch (ivo.welch at gmail.com)
>
> ______________________________________________
> R-help at 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.



More information about the R-help mailing list