[R] Index of a Loop Variable?

Patrick Connolly p.connolly at hortresearch.co.nz
Wed Apr 7 01:33:54 CEST 2004


On Tue, 06-Apr-2004 at 03:55PM -0700, Jim Java wrote:

|> 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

Depending on what you do with the index in the loop, it's simple
enough to use the names of a list instead of the indexes.  For
example, you can use the part of the list identified by its name
without needing to know what its index is.

for(i in names(xx)){
  do.something(xx[[i]], ...)
  etc
}

But if it's the index you need, the answer would be No.

HTH


-- 
Patrick Connolly
HortResearch
Mt Albert
Auckland
New Zealand 
Ph: +64-9 815 4200 x 7188
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~
I have the world`s largest collection of seashells. I keep it on all
the beaches of the world ... Perhaps you`ve seen it.  ---Steven Wright 
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~




More information about the R-help mailing list