[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

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 having

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

2007-05-15 Thread Talbot Katz
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 [EMAIL PROTECTED],r-help@stat.math.ethz.ch Subject: RE: [R] Testing for existence inside a function

Re: [R] Testing for existence inside a function

2007-05-15 Thread Liaw, Andy
. -- TMK -- 212-460-5430 home 917-656-5351 cell 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 [Broadcast] Date: Tue, 15 May 2007 11:03:12 -0400 Not sure which one you want

Re: [R] Testing for existence inside a function

2007-05-15 Thread Talbot Katz
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 Date: Tue, 15 May 2007 11:41:17 -0400 Just need a bit more work

Re: [R] Testing for existence inside a function

2007-05-15 Thread Gabor Grothendieck
-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 Date: Tue, 15 May 2007 11:41:17 -0400 Just need a bit more work: R f - function(x) exists(deparse(substitute(x))) R f(y

Re: [R] Testing for existence inside a function

2007-05-15 Thread Liaw, Andy
! -- 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 Date: Tue, 15 May 2007 11:41:17 -0400 Just need a bit more work: R f

Re: [R] Testing for existence inside a function

2007-05-15 Thread Gabor Grothendieck
-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 Date: Tue, 15 May 2007 11:41:17 -0400 Just need a bit more work: R f - function(x) exists(deparse

Re: [R] Testing for existence inside a function

2007-05-15 Thread Bert Gunter
-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 this: chk2 - function(x

Re: [R] Testing for existence inside a function

2007-05-15 Thread Gabor Grothendieck
-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 this: chk2 - function(x

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: f(y)

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-function(x){ ...

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 in R. R doesn't