Is there any function in R like
is.not.found(x, y)
meaning if you can't find object x, then use object
y??
Mikkel Grum
__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide!
rm(list=ls())
a - 1
ifelse(exists(b), b, a)
[1] 1
b - 2
ifelse(exists(b), b, a)
[1] 2
Gabor
On Fri, Jan 27, 2006 at 04:38:39AM -0800, Mikkel Grum wrote:
Is there any function in R like
is.not.found(x, y)
meaning if you can't find object x, then use object
y??
Mikkel Grum
On 1/27/2006 7:48 AM, Gabor Csardi wrote:
rm(list=ls())
a - 1
ifelse(exists(b), b, a)
[1] 1
b - 2
ifelse(exists(b), b, a)
[1] 2
That's not quite right. ifelse() is meant for vectors of conditions;
you really want just plain old if here:
if (exists(b)) b else a
For example, with no b
This does not answer your question directly but this
can relate to calling functions and also to inheritance
in object oriented systems. The common thread in
1b and 2 is that if a variable is not found in the current
environment R will look into the parent environment so if we
give our variables
On 27 Jan 2006, [EMAIL PROTECTED] wrote:
Is there any function in R like
is.not.found(x, y)
meaning if you can't find object x, then use object
y??
Along with exists(), you might find mget() useful since it allows you
to specify an ifnotfound value.
--
+ seth