Re: [R] Argument validation within functions

2011-12-06 Thread Bert Gunter
) stops the total function... So there is just >> > one little other question: What is the opposite of is.numeric? >> > Is ther isnot.numeric? How  can that be implemented in following >> > function: >> > >> > f <- function(a){ >> >        if(is.numeric(a)

Re: [R] Argument validation within functions

2011-12-06 Thread Enrico Schumann
Datum: Tue, 6 Dec 2011 07:57:44 -0500 Von: "R. Michael Weylandt" An: r-help, Johannes Radinger Betreff: Re: [R] Argument validation within functions Use the ! (not) operator. Not sure what you mean by " as the stop() stops the total function": try the following f<-

Re: [R] Argument validation within functions

2011-12-06 Thread Berwin A Turlach
G'day Johannes, On Tue, 06 Dec 2011 16:15:21 +0100 "Johannes Radinger" 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 <-f

Re: [R] Argument validation within functions

2011-12-06 Thread Johannes Radinger
the function call not outside the function or before etc. /Johannes Original-Nachricht > Datum: Tue, 6 Dec 2011 07:57:44 -0500 > Von: "R. Michael Weylandt" > An: r-help , Johannes Radinger > Betreff: Re: [R] Argument validation within functions > Use the ! (n

Re: [R] Argument validation within functions

2011-12-06 Thread R. Michael Weylandt
hannes > > Original-Nachricht >> Datum: Tue, 6 Dec 2011 07:04:59 -0500 >> Von: "R. Michael Weylandt" >> An: Johannes Radinger >> CC: r-help@r-project.org >> Betreff: Re: [R] Argument validation within functions > >> T

Re: [R] Argument validation within functions

2011-12-06 Thread Uwe Ligges
Tue, 6 Dec 2011 07:04:59 -0500 Von: "R. Michael Weylandt" An: Johannes Radinger CC: r-help@r-project.org Betreff: Re: [R] Argument validation within functions The quick and dirty way to do so is to use: stopifnot() in conjunction (if necessary with all() and any()). You can replace t

Re: [R] Argument validation within functions

2011-12-06 Thread Johannes Radinger
annes Radinger > CC: r-help@r-project.org > Betreff: Re: [R] Argument validation within functions > The quick and dirty way to do so is to use: stopifnot() in conjunction > (if necessary with all() and any()). You can replace that first > condition with a simple is.numeric()

Re: [R] Argument validation within functions

2011-12-06 Thread R. Michael Weylandt
The quick and dirty way to do so is to use: stopifnot() in conjunction (if necessary with all() and any()). You can replace that first condition with a simple is.numeric() as well. A more helpful way (if this is production code) is to use if statement with the stop() function directly which lets yo