Skip to content
Prev 279496 / 398506 Next

Argument validation within functions

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.

/Johannes

-------- Original-Nachricht --------
--