[R] calling "exists" function inside another function is not working
utkarshsinghal
utkarsh.singhal at global-analytics.com
Sat May 14 09:30:17 CEST 2011
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. 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
More information about the R-help
mailing list