-4

I have a simple loop

for(z in 1:length(x)){
country=region_names[z]
//paste("xyz",country)//
....
}

Now, after the loop is finished, z will have the value equal to the length of x.

Now, I need to find a way to add an iterator.

Supposedly, when it is at the second loop, iterator=2, it will show "xyzUSA".

Supposedly, when it is at the third loop, iterator=3, it will show "xyzFrance"

My problem is, I don't need to show them all at once, but when the iterator is triggered, the program knows what the value of iterator is, and shows the corresponding country.

Now, how can I build an iterator like this?

Any help is appreciated

Weijia
  • 79
  • 9
  • 1
    You need to provide a reproducible example. I don't really understand what you are trying to do, but it doesn't read like you should use a loop. – Roland Apr 09 '14 at 15:48
  • @Roland, I don't have a reproducible example yet, this is all in experiments. I edited my text, I hope this makes more sense to you. But really which part you don't understand? – Weijia Apr 09 '14 at 15:55
  • 2
    I can't speak for Roland, but the part of the question _I_ don't understand is "all of it". – joran Apr 09 '14 at 15:58
  • I'm with joran on this one. What you want to do isn't clear to me at all. – Dason Apr 09 '14 at 16:10

1 Answers1

-1

To all people who cannot understand my question, I myself figured it out.

It was an issue of lazy evaluation. It can be solved by using

force()

Sorry about the confusion, your help is appreciated.

Weijia
  • 79
  • 9