Thanks to everyone who's responded to my request for info -- the replies have been helpful and interesting. They'll certainly help me towards thinking more cleverly in R....
Barry: I'd like to see your looping class, but only if you haven't anything better to do over your break than trying to put it together again. :) -- Jim J. > -----Original Message----- > From: [EMAIL PROTECTED] [mailto:r-help- > [EMAIL PROTECTED] On Behalf Of Gabor Grothendieck > Sent: Wednesday, April 07, 2004 12:30 AM > To: [EMAIL PROTECTED] > Subject: Re: [R] Index of a Loop Variable? > > You could define the utility function iter: > > iter <- function(x) mapply( x, seq(along=x), > FUN=function(x,i)list(x=x,i=i), SIMPLIFY=F ) > > and use it like this to loop over seq(5,50,5) and 1:10 simultaneously: > > > for(idx in iter(seq(5,50,5))) with(idx, cat(x,i,"\n")) > 5 1 > 10 2 > 15 3 > 20 4 > 25 5 > 30 6 > 35 7 > 40 8 > 45 9 > 50 10 > > Jim Java writes-- > > Hi Everyone:-- > > Is it possible, within a for loop not explicitly using whole-number > indexing, to find out the index value of the loop variable within the > vector or list that's being looped through? ______________________________________________ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
