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. ft. -- Fernando TUSELL e-mail: Departamento de Econometr?a y Estad?stica etptupaf at bs.ehu.es Facultad de CC.EE. y Empresariales Tel: (+34)94.601.3733 Avenida Lendakari Aguirre, 83 Fax: (+34)94.601.3754 E-48015 BILBAO (Spain) Secr: (+34)94.601.3740 PGP: finger etptupaf at bsdx01.bs.ehu.es http://agesi.bs.ehu.es ---------------------------------------------------------------------- -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
"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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
"F.Tusell":> > 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.This should work: my.funs <- names((x <- sapply(ls(), function(y){is.function(get(y))}))[x==TRUE]) for(i in 1:length(all.funs)) dump(list=(temp <- my.funs[i]), fileout=paste(temp, ".R")) (in .....fileout=paste(.)....) you could specify the path additionally) Regards, Uwe Ligges -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._