Re: [R] calling "exists" function inside another function is not working

From: utkarshsinghal <utkarsh.singhal_at_global-analytics.com>
Date: Sat, 14 May 2011 17:19:32 +0530

Thanks David. Big help, problem solved.

Regards,
Utkarsh

>
> On May 14, 2011, at 3:30 AM, utkarshsinghal wrote:
>
>>
>> Hi all,
>> I want to define a function such that one of its argument if passed do
>> one
>> thing and if not passed do the second thing.
>
> ?missing
>
>> So basically, I have to check
>> whether the argument is passed or not inside the function. I am trying to
>> use 'exists' function to do this.
>>> f = function(a,b){exists("b")}
>>> f(a=3, b=4)
>> [1] TRUE
>> This is working as expected.
>> But if I do the following:
>>> f(a=3)
>> [1] TRUE
>> Can anybody explain why this function is returning TRUE here.
>> --
>> Many thanks,
>> Utkarsh
>> ______________________________________________
>> R-help_at_r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>
> David Winsemius, MD
> West Hartford, CT
>
>



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Sat 14 May 2011 - 11:52:39 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sat 14 May 2011 - 12:20:06 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive