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
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
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:
>
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
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
titute(objn
> > > + }
> > > >exists("objn")
> > > [1] FALSE
> > > >chkex5(objn)
> > > exob
> > > TRUE
> > > >
> > >
> > > But I suppose I can live with this. Thanks again!
> > >
> > >
&g
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
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]
;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:
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
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
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
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
13 matches
Mail list logo