Tribo Laboy
2008-Apr-07 06:13 UTC
[R] How to pack my stuff into a package (library, collection)?
Hello, I am new useR, I have written some functions, which I currently use by "source"-ing them from the files. That's OK, but when I my functions start counting in the tens and hundreds I'd be glad to be able to type "help.search("my_obscure_fun")" and get a sensible reply. I also want to be able to load them as a package at startup and not have to "source" each one individually. I read through the "Writing R Extensions" file, but I am overwhelmed with the vast amount of prescribed detail that Extension Authors must follow - directory structure, file structure, etc. Luckily, I found the "prompt" function, which helps in writing of help-files in the form of "fill-in the blanks". But that's only for the help-files. Reading further, it gets even more complicated. The user is referred to the "R Installation and Administration" document, which says that: If you want to build R or add-on packages from source in Windows, you will need to collect, install and test an extensive set of tools. These seem to include among others Perl and compiler. But R is an interpreted and cross-platform language, I don't understand the need for additional platform specific tools just to call a user collection of R-files. Anyone knows of a smooth introduction to these topics? Rgards, TL
Simon Blomberg
2008-Apr-07 06:49 UTC
[R] How to pack my stuff into a package (library, collection)?
On Mon, 2008-04-07 at 15:13 +0900, Tribo Laboy wrote:> Hello, > > I am new useR, I have written some functions, which I currently use by > "source"-ing them from the files. > That's OK, but when I my functions start counting in the tens and > hundreds I'd be glad to be able to type > "help.search("my_obscure_fun")" and get a sensible reply. I also want > to be able to load them as a package at startup and not have to > "source" each one individually. I read through the "Writing R > Extensions" file, but I am overwhelmed with the vast amount of > prescribed detail that Extension Authors must follow - directory > structure, file structure, etc. Luckily, I found the "prompt" > function, which helps in writing of help-files in the form of "fill-in > the blanks". But that's only for the help-files. Reading further, it > gets even more complicated. The user is referred to the "R > Installation and Administration" document, which says that: > > If you want to build R or add-on packages from source in Windows, you > will need to collect, install and test an extensive set of tools. > > These seem to include among others Perl and compiler. But R is an > interpreted and cross-platform language, I don't understand the need > for additional platform specific tools just to call a user collection > of R-files. Anyone knows of a smooth introduction to these topics? >Have a look at ?package.skeleton. It should get you started. If you just want to build packages with pure R (no shared libraries etc.), I think you won't need the other tools. Cheers, Simon.> Rgards, > TL > > ______________________________________________ > 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.-- Simon Blomberg, BSc (Hons), PhD, MAppStat. Lecturer and Consultant Statistician Faculty of Biological and Chemical Sciences The University of Queensland St. Lucia Queensland 4072 Australia Room 320 Goddard Building (8) T: +61 7 3365 2506 http://www.uq.edu.au/~uqsblomb email: S.Blomberg1_at_uq.edu.au Policies: 1. I will NOT analyse your data for you. 2. Your deadline is your problem. The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data. - John Tukey.
Tribo Laboy a ?crit :> Hello, > I am new useR, I have written some functions, which I currently use by > "source"-ing them from the files. > That's OK, but when I my functions start counting in the tens and > hundreds I'd be glad to be able to type > "help.search("my_obscure_fun")" and get a sensible reply. I also want > to be able to load them as a package at startup and not have to > "source" each one individually.Why not simply use a function doing that. (That's how I proceed). You can call it in .First()> I read through the "Writing R > Extensions" file, but I am overwhelmed with the vast amount of > prescribed detail that Extension Authors must follow - directory > structure, file structure, etc. Luckily, I found the "prompt" > function, which helps in writing of help-files in the form of "fill-in > the blanks". But that's only for the help-files.I did an horrible hack (rerouting an existing package help directory) for simply having ? callable html help files for my own functions. Sad, but seems simpler than downloading X Mo of stuff just for that.
Hans W. Borchers
2008-Apr-07 07:55 UTC
[R] How to pack my stuff into a package (library, collection)?
Tribo Laboy <tribolaboy <at> gmail.com> writes:> [...] > These seem to include among others Perl and compiler. But R is an > interpreted and cross-platform language, I don't understand the need > for additional platform specific tools just to call a user collection > of R-files. Anyone knows of a smooth introduction to these topics?There is a small 15-pages tutorial: "Making R Packages Under Windows: A Simple Guide" by P. Rossi http://faculty.chicagogsb.edu/peter.rossi/research/bayes%20book/bayesm/ Making%20R%20Packages%20Under%20Windows.pdf that might be helpful as a step-by-step instruction. Hans Werner
Tribo Laboy
2008-Apr-08 11:08 UTC
[R] How to pack my stuff into a package (library, collection)?
Thanks all for the help and suggestions. I am little by little finding my way. I have another question to the people who use the R packaging system. Say I have a function called "myfun.R". Where am I supposed to write the help to that function? When I use promt("myfun") or package.skeleton("myfun") I get a skeleton of the .Rd file which contains both help and R source. What do you do with the original .R source file then - do you delete it? I suppose it is not necessary anymore and all changes to R source and help can be done simultaneously in the .Rd file. Then it can be used to generate all the help and R files to be run. But then .Rd files cannot be run directly from R, so each time a change is done to the source, it must be re-exported in an .R file and run. Please tell me if I am wrong. Do you keep R-souce and R-help in separate files while developing and then combine them in a single .Rd file when you're finished? Yours still confused, TL On Mon, Apr 7, 2008 at 3:13 PM, Tribo Laboy <tribolaboy at gmail.com> wrote:> Hello, > > I am new useR, I have written some functions, which I currently use by > "source"-ing them from the files. > That's OK, but when I my functions start counting in the tens and > hundreds I'd be glad to be able to type > "help.search("my_obscure_fun")" and get a sensible reply. I also want > to be able to load them as a package at startup and not have to > "source" each one individually. I read through the "Writing R > Extensions" file, but I am overwhelmed with the vast amount of > prescribed detail that Extension Authors must follow - directory > structure, file structure, etc. Luckily, I found the "prompt" > function, which helps in writing of help-files in the form of "fill-in > the blanks". But that's only for the help-files. Reading further, it > gets even more complicated. The user is referred to the "R > Installation and Administration" document, which says that: > > If you want to build R or add-on packages from source in Windows, you > will need to collect, install and test an extensive set of tools. > > These seem to include among others Perl and compiler. But R is an > interpreted and cross-platform language, I don't understand the need > for additional platform specific tools just to call a user collection > of R-files. Anyone knows of a smooth introduction to these topics? > > Rgards, > TL >
Martin Maechler
2008-Apr-08 14:07 UTC
[R] How to pack my stuff into a package (library, collection)?
>>>>> "TL" == Tribo Laboy <tribolaboy at gmail.com> >>>>> on Tue, 8 Apr 2008 22:15:13 +0900 writes:TL> okey-dokey, one more problem resolved. TL> Keeping one documentation .Rd file for each R source file. not at all ... you still think "Matlab" One R source file typically contains several function (and maybe class and method) definitions. Often on Rd file contains documentation for more than one object. Look at the R sources , at any package sources (i.e. not the *.zip, but the *.tar.gz files). Martin Maechler, ETH Zurich
Maybe Matching Threads
- More elegant multiplication or division of a data frame with a vector
- Plotting series marked with a symbol on every nth data point, preferably in ggplot...
- Combining several mappings in ggplot2
- How to assign multiple return values
- Moving data between R and Matlab back and forth?