[R] Argument validation within functions
Berwin A Turlach
Berwin.Turlach at gmail.com
Tue Dec 6 16:36:46 CET 2011
G'day Johannes,
On Tue, 06 Dec 2011 16:15:21 +0100
"Johannes Radinger" <JRadinger at gmx.at> wrote:
> Thank you, i didn't know that the !operator is
> also working for is.numeric etc.
>
> Anyway I want to test if an argument is set in the
> function call and if not a code is executed... So
> far I tried:
>
> f <-function(a,b){
> if(!exists("b")) print("exists: b is not set")
> if(is.null("b")) print("is.null : b is not set")
> }
>
> f(a=1,b=2)
> f(a=1)
> f(b=2)
>
> I don't really know how to do it...e.g: for f(a=1) b is not set
> so it also can't be NULL (thats why is.null is not working). I
> just want to "test" if it is set with the function call not outside
> the function or before etc.
?missing
Cheers,
Berwin
========================== Full address ============================
A/Prof Berwin A Turlach Tel.: +61 (8) 6488 3338 (secr)
School of Maths and Stats (M019) +61 (8) 6488 3383 (self)
The University of Western Australia FAX : +61 (8) 6488 1028
35 Stirling Highway
Crawley WA 6009 e-mail: Berwin.Turlach at gmail.com
Australia http://www.maths.uwa.edu.au/~berwin
More information about the R-help
mailing list