Home How to get index in a loop in R
Reply: 0

How to get index in a loop in R

user489 Published in July 21, 2018, 2:57 pm

I have a vector of character type which has all the list of names.

So I'm looping through each name and peforming some actions. This loop is not based on the index/length (and I want to keep it this way).

However, if I want to access the index value in the loop how do I get it.


names <- c("name1", "name2")

for(name in names){

#do something

#here how would I get the index number? like 1, 2 etc?

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.317451 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO