[R] R equiv of #ifdef?
Kurt Hornik
Kurt.Hornik at ci.tuwien.ac.at
Mon Jun 7 11:44:58 CEST 1999
>>>>> Bill Simpson writes:
> 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.
Try exists().
-k
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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