On Sat, Jul 9, 2011 at 2:37 PM, Abhijit Dasgupta, PhD <aikidasgu...@gmail.com> wrote: > I think most of us are in a similar situation. I've usually kept mine in a > file which is sourced when I start R. The main problem I have with this is > that it clutters up my environment with a lot of stuff I don't need all the > time. I'm in the process of creating a custom package which will be > lazy-loaded. I believe a previous discussion of this topic suggested this as > the preferred method. >
If you dont want to make a package there's a few ways of doing this without cluttering up your environment. For example: * Create a functions.RData from your functions.R file whenever you edit your functions.R file, by starting a vanilla R session, sourcing functions.R, then using save. Then in your working sessions just attach/detach the functions.RData file. * Create a new environment, source functions.R into it, and attach it. Something like: e = new.env() with(e,source("functions.R",local=TRUE)) attach(e) now the functions defined in functions.R are in the 'e' environment, and since e is attached R will find them. Some R authors have written systems for doing this kind of thing, with easy ways of updating when the source changes. See, I think, mvbutils on CRAN, for this kind of thing on steroids. Barry ______________________________________________ R-help@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.