[R] A question about function behavior

Sundar Dorai-Raj sundar.dorai-raj at pdf.com
Wed Apr 20 21:25:01 CEST 2005



Jorge Ahumada wrote on 4/20/2005 12:02 PM:
> 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
> 


I think you want ?pmax instead of ?max.

--sundar




More information about the R-help mailing list