[R] Index of a Loop Variable?
Jim Java
jjava at priscian.com
Wed Apr 7 00:55:21 CEST 2004
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? For example, in --
x <- seq(5, 50, by=5)
index.in.x <- 1
for (i in x) {
cat(paste(" index of i-value ", i, " within x: ", index.in.x, sep=""), fill=T)
index.in.x <- index.in.x + 1
}
-- is it in general possible to get values of "index.in.x" without
making it a count variable, as above?
Thank you.
-- Jim Java
More information about the R-help
mailing list