Simon Chamaillé-Jammes
2011-Jul-09 11:30 UTC
[R] Storing and managing custom R functions for re-use
Dear all, sorry if this is a bit on the sidetrack for R-help. As a regular R user I have developed quite a lot of custom R functions, to the point of not always remembering what I have already programmed, where the file is and so on. I was wondering what other people do in this regards. A basic file with all your functions, or a custom R package, or directly integrated into a profile file ??? I'm considering that a blog with tagged posts may be a good solution (and really good ones could join R-bloggers maybe). If someone is happy to share what (s)he considers good practice, thanks. simon
I personally place functions like this in my .First function under the .Rprofile, making them instantly accessible. I also keep a function called my.fun() which lists a data frame containing a column of all the function names, one for arguments, and a brief description. This also goes in .First. Again, this makes it easy to quickly reference what you have and makes all your functions quickly accessible. Tyler> Date: Sat, 9 Jul 2011 13:30:51 +0200 > From: s.chamaille@yahoo.fr > To: r-help@r-project.org > Subject: [R] Storing and managing custom R functions for re-use > > Dear all, > > sorry if this is a bit on the sidetrack for R-help. > > As a regular R user I have developed quite a lot of custom R functions, > to the point of not always remembering what I have already programmed, > where the file is and so on. > I was wondering what other people do in this regards. A basic file with > all your functions, or a custom R package, or directly integrated into a > profile file ??? I'm considering that a blog with tagged posts may be a > good solution (and really good ones could join R-bloggers maybe). > > If someone is happy to share what (s)he considers good practice, thanks. > > simon > > ______________________________________________ > 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.[[alternative HTML version deleted]]
Abhijit Dasgupta, PhD
2011-Jul-09 13:37 UTC
[R] Storing and managing custom R functions for re-use
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. On 07/09/2011 07:30 AM, Simon Chamaill?-Jammes wrote:> Dear all, > > sorry if this is a bit on the sidetrack for R-help. > > As a regular R user I have developed quite a lot of custom R > functions, to the point of not always remembering what I have already > programmed, where the file is and so on. > I was wondering what other people do in this regards. A basic file > with all your functions, or a custom R package, or directly integrated > into a profile file ??? I'm considering that a blog with tagged posts > may be a good solution (and really good ones could join R-bloggers > maybe). > > If someone is happy to share what (s)he considers good practice, thanks. > > simon > > ______________________________________________ > 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.
On 07/09/2011 09:30 PM, Simon Chamaill?-Jammes wrote:> Dear all, > > sorry if this is a bit on the sidetrack for R-help. > > As a regular R user I have developed quite a lot of custom R functions, > to the point of not always remembering what I have already programmed, > where the file is and so on. > I was wondering what other people do in this regards. A basic file with > all your functions, or a custom R package, or directly integrated into a > profile file ??? I'm considering that a blog with tagged posts may be a > good solution (and really good ones could join R-bloggers maybe). > > If someone is happy to share what (s)he considers good practice, thanks.Hi Simon, This may or may not be good practice, but once I worked out how to make packages (see any of the tutorials on this), I just made a little package for each group of functions. Three of them grew up to be packages on CRAN, so it worked well for me. I think having the functions segregated into packages with an easy to recognise theme like the <blatant advertisement> clinsig package </blatant advertisement>, helps to organize the work for later use. Jim
Duncan Murdoch
2011-Jul-10 00:03 UTC
[R] Storing and managing custom R functions for re-use
On 11-07-09 7:30 AM, Simon Chamaill?-Jammes wrote:> Dear all, > > sorry if this is a bit on the sidetrack for R-help. > > As a regular R user I have developed quite a lot of custom R functions, > to the point of not always remembering what I have already programmed, > where the file is and so on.You really need to put these in a package. Besides being an organized place to hold code, packages have all sorts of documentation support. You'll be able to browse your help pages to see what you've already got, what the arguments mean, etc. Of course, writing good documentation is harder than writing minimal documentation, but R (almost) does the latter for you, so it's hardly more difficult than writing none at all, but it's a lot more useful. Duncan Murdoch> I was wondering what other people do in this regards. A basic file with > all your functions, or a custom R package, or directly integrated into a > profile file ??? I'm considering that a blog with tagged posts may be a > good solution (and really good ones could join R-bloggers maybe). > > If someone is happy to share what (s)he considers good practice, thanks. > > simon > > ______________________________________________ > 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.
Michael Dewey
2011-Jul-10 10:27 UTC
[R] Storing and managing custom R functions for re-use
At 12:30 09/07/2011, Simon Chamaill?-Jammes wrote:>Dear all, > >sorry if this is a bit on the sidetrack for R-help. > >As a regular R user I have developed quite a lot >of custom R functions, to the point of not >always remembering what I have already programmed, where the file is and so on. >I was wondering what other people do in this >regards. A basic file with all your functions, >or a custom R package, or directly integrated >into a profile file ??? I'm considering that a >blog with tagged posts may be a good solution >(and really good ones could join R-bloggers maybe). > >If someone is happy to share what (s)he considers good practice, thanks.I spent too many years doing what you say you are doing because creating a package seemed quite complicated. Once I took the plunge I found it well worth the effort. You do have to invest time and effort to begin with. You will find ?package.skeleton ?prompt rewarding reading as well as those sections of the R extensions document which are relevant to your use. Good luck>simon > >Michael Dewey info at aghmed.fsnet.co.uk http://www.aghmed.fsnet.co.uk/home.html