Message-ID: <760e842f21af3fe0cc61a48e7130a950@usgs.gov>
Date: 2005-04-20T19:27:39Z
From: Jorge Ahumada
Subject: A question about function behavior
In-Reply-To: <010801c545da$942336d0$c95c8453@c10qkmdlzis1xp>
Thank you very much for all the answers. pmax works great!
Jorge
On Apr 20, 2005, at 1:55 PM, Alexandre Brito wrote:
> I think you want this:
>
> b<- function(t) {pmax(0,t+1)}
>
> alex
>
>
> ----- Original Message -----
> From: "Jorge Ahumada" <jahumada at usgs.gov>
> To: <r-help at stat.math.ethz.ch>
> Sent: Wednesday, April 20, 2005 6:02 PM
> Subject: [R] A question about function behavior
>
>
>> Hello,
>>
>> I have been trying to figure this one out, but don't seem to go
>> anywhere. I have a function like this:
>>
>> a = function(t) {
>>
>> max(0,t+1)
>>
>> }
>>
>> very simple, but if I pass a vector of n values to this function I
>> expect n evaluations of max and instead I get only one value (the
>> largest value of them all..). Is there anyway to do this without
>> invoking a for loop?
>>
>> thanks,
>>
>> Jorge
>>
>> ______________________________________________
>> R-help at stat.math.ethz.ch mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html
>>
>