[R] Dumping functions to RCS
Douglas Bates
bates at stat.wisc.edu
Fri Apr 28 16:08:36 CEST 2000
"F.Tusell" <etptupaf at bs.ehu.es> writes:
> To keep track of an ongoing programming project, I would like to dump
> all my functions to individual ASCII files named xxx.R, yyy.R, etc.
> Presently I do so manually in order to use RCS (on a Linux machine),
> so I can keep track of all versions, differences, snapshots, etc.
>
> Is there any easy way to dump all functions in the workspace to
> individually named files? Thank you very much for any ideas.
You can use dump() in a loop over the result of objects(). I added
one enhancement below to select only the functions.
> sqr <- function(X) X^2
> cube <- function(X) X^3
> x <- 1:3
> for (obj in objects()) { # produces files sqr.R and cube.R
+ if (is.function(get(obj))) {
+ dump(obj, fileout = paste(obj, ".R", sep = ''))
+ }
+ }
I think the preferred solution is to create your own R package and to
use RCS (or CVS) to maintain the source directories for the package.
Creating packages for R is actually rather easy now that scripts like
R CMD build <pkgname>
are available. The process is described in the manual "Writing R
Extensions".
--
Douglas Bates bates at stat.wisc.edu
Statistics Department 608/262-2598
University of Wisconsin - Madison http://www.stat.wisc.edu/~bates/
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list