Re: [R] 'require' equivalent for local functions

2009-03-23 Thread JiHO
Thanks very much to everyone. I think I will use a combination of both techniques. On 2009-March-22 , at 20:08 , Duncan Murdoch wrote: That's pretty hard to make bulletproof. Why not just put those functions in a package, and use that package? I know it will be impossible to make bullet

Re: [R] 'require' equivalent for local functions

2009-03-22 Thread Ken-JP
I agree with Duncan. I used to do exactly what you did - source()ing data files inside a wrapper not unlike C #define wrappers, but it became a headache with more files and the files began looking more cluttered. It has taken me several days to learn about how create a package properly, along wi

Re: [R] 'require' equivalent for local functions

2009-03-22 Thread Duncan Murdoch
On 22/03/2009 5:05 PM, JiHO wrote: Hello everyone, I often create some local "libraries" of functions (.R files with only functions in them) that I latter call. In scripts that call a function from such library, I would like to be able to test whether the function is already known in the n

Re: [R] 'require' equivalent for local functions

2009-03-22 Thread Wacek Kusnierczyk
JiHO wrote: > Hello everyone, > > I often create some local "libraries" of functions (.R files with only > functions in them) that I latter call. In scripts that call a function > from such library, I would like to be able to test whether the > function is already known in the namespace and, only i

Re: [R] 'require' equivalent for local functions

2009-03-22 Thread Gabor Grothendieck
Try this: if (!exists("myfun", mode = "function")) source("myfile.R") Also check the other arguments of exists in case you want to restrict the search. On Sun, Mar 22, 2009 at 5:05 PM, JiHO wrote: > Hello everyone, > > I often create some local "libraries" of functions (.R files with only > fun

[R] 'require' equivalent for local functions

2009-03-22 Thread JiHO
Hello everyone, I often create some local "libraries" of functions (.R files with only functions in them) that I latter call. In scripts that call a function from such library, I would like to be able to test whether the function is already known in the namespace and, only if it is not, s