[R] A question about function behavior

A.J. Rossini blindglobe at gmail.com
Wed Apr 20 20:29:45 CEST 2005


Perhaps by using apply? 

What do you think  that 

max(0,c(1,2,3,4)+1) 

should return?

On 4/20/05, Jorge Ahumada <jahumada at usgs.gov> wrote:
> 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
> 


-- 
best,
-tony

"Commit early,commit often, and commit in a repository from which we can easily
roll-back your mistakes" (AJR, 4Jan05).

A.J. Rossini
blindglobe at gmail.com




More information about the R-help mailing list