Re: [R] Testing for existence inside a function

2007-05-15 Thread Alberto Monteiro
Duncan Murdoch wrote: > >> Try this: >> >> f <- function(x) x + 1 >> f(y.does.not.exist) >> y.does.not.exist >> >> The error message is (almost) the same, and it happens when >> parsing the line. There's no way to change f to change this. > > That description is true in some languages, but not

Re: [R] Testing for existence inside a function

2007-05-15 Thread Duncan Murdoch
On 5/15/2007 3:06 PM, Alberto Monteiro wrote: > Talbot Katz wrote: >> >> I'm having trouble testing for existence of an object inside a function. >> > No, you are having trouble testing for existence of an object > _before_ the function is called :-) > >> Suppose I have a function: >> >> f<-fun

Re: [R] Testing for existence inside a function

2007-05-15 Thread Alberto Monteiro
Talbot Katz wrote: > > I'm having trouble testing for existence of an object inside a function. > No, you are having trouble testing for existence of an object _before_ the function is called :-) > Suppose I have a function: > > f<-function(x){ > ... > } > > and I call it with argument y: >

Re: [R] Testing for existence inside a function

2007-05-15 Thread Gabor Grothendieck
gt; > > argument name in > > > > my user-defined function, and that object "x" does not > > > exist. If I call the > > > > function f(x), i.e., using the non-existent object x as the > > > argument value, > > > > then the f

Re: [R] Testing for existence inside a function

2007-05-15 Thread Bert Gunter
ter Genentech Nonclinical Statistics -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Gabor Grothendieck Sent: Tuesday, May 15, 2007 10:06 AM To: Liaw, Andy Cc: r-help@stat.math.ethz.ch; Talbot Katz Subject: Re: [R] Testing for existence inside a function Maybe

Re: [R] Testing for existence inside a function

2007-05-15 Thread Gabor Grothendieck
titute(objn > > > + } > > > >exists("objn") > > > [1] FALSE > > > >chkex5(objn) > > > exob > > > TRUE > > > > > > > > > > But I suppose I can live with this. Thanks again! > > > > > > &g

Re: [R] Testing for existence inside a function

2007-05-15 Thread Liaw, Andy
t; > > > But I suppose I can live with this. Thanks again! > > > > > > -- TMK -- > > 212-460-5430home > > 917-656-5351cell > > > > > > > > >From: "Liaw, Andy" <[EMAIL PROTECTED]> > > >To: "Ta

Re: [R] Testing for existence inside a function

2007-05-15 Thread Gabor Grothendieck
sts("objn") > [1] FALSE > >chkex5(objn) > exob > TRUE > > > > But I suppose I can live with this. Thanks again! > > > -- TMK -- > 212-460-5430 home > 917-656-5351 cell > > > > >From: "Liaw, Andy" <[EMAIL PROTECTED]

Re: [R] Testing for existence inside a function

2007-05-15 Thread Talbot Katz
;chkex5(objn) exob TRUE > But I suppose I can live with this. Thanks again! -- TMK -- 212-460-5430home 917-656-5351cell >From: "Liaw, Andy" <[EMAIL PROTECTED]> >To: "Talbot Katz" <[EMAIL PROTECTED]>,r-help@stat.math.ethz.ch >Subject:

Re: [R] Testing for existence inside a function

2007-05-15 Thread Liaw, Andy
haps what I'm attempting to do is unavailable > because it's a bad > programming paradigm. But even an explanation if that's the > case would be > appreciated. > > -- TMK -- > 212-460-5430 home > 917-656-5351 cell > > > > >From: "L

Re: [R] Testing for existence inside a function [Broadcast]

2007-05-15 Thread Talbot Katz
ting to do is unavailable because it's a bad programming paradigm. But even an explanation if that's the case would be appreciated. -- TMK -- 212-460-5430home 917-656-5351cell >From: "Liaw, Andy" <[EMAIL PROTECTED]> >To: "Talbot Katz" <[EMAI

Re: [R] Testing for existence inside a function [Broadcast]

2007-05-15 Thread Liaw, Andy
Not sure which one you want, but the following should cover it: R> f <- function(x) c(x=missing(x), y=exists("y")) R> f(1) x y FALSE FALSE R> f() x y TRUE FALSE R> y <- 1 R> f() xy TRUE TRUE R> f(1) x y FALSE TRUE Andy From: Talbot Katz > > Hi. > > I'm

[R] Testing for existence inside a function

2007-05-15 Thread Talbot Katz
Hi. I'm having trouble testing for existence of an object inside a function. Suppose I have a function: f<-function(x){ ... } and I call it with argument y: f(y) I'd like to check inside the function whether argument y exists. Is this possible, or do I have to either check outside the funct