On 6/10/07, gallon li <[EMAIL PROTECTED]> wrote: > Suppose I have a vector A=c(1,2,3) > > now I want to compare each element of A to another vector L=c(0.5, 1.2) > > and then recode values for sum(A>0.5) and sum(A>1.2) > > to get a result of (3,2) > > how can I get this without writing a loop of sums?
How about colSums(outer(A, L, ">")) Hadley ______________________________________________ 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 and provide commented, minimal, self-contained, reproducible code.