[R] Introduce a new function in a package?

2005-04-06 Thread Luis Ridao Cruz
R-help, Sometimes I define functions I wish to have in any R session. The obvious thing to do is copy-paste the code The thing is that sometimes I don't know where I have the function code. My question is if somehow I could define a function and introduce it (let's say 'base' package ) so that

Re: [R] Introduce a new function in a package?

2005-04-06 Thread Roger D. Peng
I think the usual way is to create an R package for yourself and load it when you need it for whatever project. -roger Luis Ridao Cruz wrote: R-help, Sometimes I define functions I wish to have in any R session. The obvious thing to do is copy-paste the code The thing is that sometimes I don't

Re: [R] Introduce a new function in a package?

2005-04-06 Thread Dimitris Rizopoulos
] Introduce a new function in a package? R-help, Sometimes I define functions I wish to have in any R session. The obvious thing to do is copy-paste the code The thing is that sometimes I don't know where I have the function code. My question is if somehow I could define a function and introduce

Re: [R] Introduce a new function in a package?

2005-04-06 Thread TEMPL Matthias
] [mailto:[EMAIL PROTECTED] Im Auftrag von Luis Ridao Cruz Gesendet: Mittwoch, 06. April 2005 15:48 An: r-help@stat.math.ethz.ch Betreff: [R] Introduce a new function in a package? R-help, Sometimes I define functions I wish to have in any R session. The obvious thing to do is copy-paste

RE: [R] Introduce a new function in a package?

2005-04-06 Thread Liaw, Andy
Another approach, if making a package is a bit more than what you want to do, is: 1. Save those functions/objects in an image using save(). 2. attach() that image every time you start R. There are a few ways that you can do #2 above. See ?Startup. Andy From: Roger D. Peng I think the

Re: [R] Introduce a new function in a package?

2005-04-06 Thread Jan T. Kim
On Wed, Apr 06, 2005 at 09:57:00AM -0400, Roger D. Peng wrote: I think the usual way is to create an R package for yourself and load it when you need it for whatever project. -roger Alternatively, one can also write the function in question into one's ~/.Rprofile; then, it's automatically

Re: [R] Introduce a new function in a package?

2005-04-06 Thread Don MacQueen
Expressions in .Rprofile are executed *before* any previously saved global environment is loaded (i.e., before the .RData file in the current working directory is loaded, causing the message [Previously saved workspace restored] to a appear). If you define a function in .Rprofile, and then

Re: [R] Introduce a new function in a package?

2005-04-06 Thread Gabor Grothendieck
Some other advantages of making your own package are: - you can use help.search to search for your own functions even if you don't load the package - if you can't even remember where your functions are (and I often can't) then you may not remember what they do either and packaging them

Re: [R] Introduce a new function in a package?

2005-04-06 Thread Josef Eschgfaeller
~/.Rprofile You could also write in .Rprofile soemthing like this: for (x in dir(Mylibrary,full.names=T,recursive=T)) source(x) where Mylibrary is a directory which contains your functions without making a package. Josef Eschgfäller__

Re: [R] Introduce a new function in a package?

2005-04-06 Thread roger bos
I tried making a package on windows and got a make error, so I was happy I was able to get source(mystuff.R) to work in .First(). Since my utility functions are pretty simple and few in number, this is good enough for me for now. But I got a curious error. I can submit the command

Re: [R] Introduce a new function in a package?

2005-04-06 Thread Prof Brian Ripley
Better to attach a new environment and source() the files into that. local({ for (.x in dir(Mylibrary,full.names=T,recursive=T)) source(.x, local=T); rm(.x)}, env = attach(NULL, name=myenv)) for all the reasons why a package() is a good idea. Leaving an object `x' around from .Rprofile is

Re: [R] Introduce a new function in a package?

2005-04-06 Thread Prof Brian Ripley
On Wed, 6 Apr 2005, roger bos wrote: I tried making a package on windows and got a make error, so I was happy I was able to get source(mystuff.R) to work in .First(). Since my utility functions are pretty simple and few in number, this is good enough for me for now. But I got a curious error. I

Re: [R] Introduce a new function in a package?

2005-04-06 Thread Josef Eschgfaeller
Leaving an object `x' around from .Rprofile is not at all a good idea, Actually I thought to put it inside a function. Josef Eschgfäller __ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting