On Tue, 12 Aug 2003, Peter Wolf wrote: > What about ... > > > unlist(lis)[which(unlist(lis)=="next")+1] > [1] "want1" "want2" > > ... to avoid the loop in sapply?
That has a loop in each unlist, of course. (A slicker version of that solution was posted earlier by Richard.) Note that you have to loop over the list elements to do this: both sapply (really lapply) and unlist do that in C code. It's not even clear to me that it is worth avoiding looping in R code: for() loops in R are pretty efficient, and the collective memory of problems in S+3.x (x < 4) is still affecting decisions today. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595 ______________________________________________ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
