RE: [R] A question about function behavior

From: Liaw, Andy <andy_liaw_at_merck.com>
Date: Thu 21 Apr 2005 - 04:31:53 EST


> From: Jorge Ahumada
>
> 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?

It works as documented. ?max says:

Value

max and min return the maximum or minimum of all the values present in their arguments, as integer if all are integer, or as double otherwise.

What you want is pmax(). [This should perhaps be included in the "See Also" section of ?max.]

Andy  

> thanks,
>
> Jorge
>
> ______________________________________________
> R-help@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
>
>
>



R-help@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 Received on Thu Apr 21 05:28:19 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:31:18 EST