[R] R equiv of #ifdef?

Bill Simpson wsimpson at gcal.ac.uk
Mon Jun 7 12:09:46 CEST 1999


I was wondering if R has an equivalent of #ifdef.
I want the code to check if a function has been sourced in yet, and if
not, then source it in. (I know of replace(), which works for
packages/libraries)

Here is what I have come up with.

my.objects<-objects()
if(my.objects[my.objects=="thingy2"]!="thingy2")
	source("~/papers/speed/junk.r")

junk.r contains the code for function thingy2().
This doesn't work: "missing value where logical needed"
The error message puzzles me.

>my.objects[my.objects=="thingy2"]!="thingy2"
logical(0)

Thanks very much for any help.

Bill Simpson

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list