[R] substituting an object not found

2006-01-27 Thread Mikkel Grum
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!

Re: [R] substituting an object not found

2006-01-27 Thread Gabor Csardi
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

Re: [R] substituting an object not found

2006-01-27 Thread Duncan Murdoch
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

Re: [R] substituting an object not found

2006-01-27 Thread Gabor Grothendieck
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

Re: [R] substituting an object not found

2006-01-27 Thread Seth Falcon
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