) 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)
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<-
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
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
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
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
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()
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
8 matches
Mail list logo