Zip or enumerate in R?
Answer for python enumerate: In R, a list is ordered (see this answer). Thus, all you need is to index either keys (using names()[i]) or values (using [[i]]). Using seq_along (alternatively can do for(i in 1:length(mylist)){…}): > mylist <- list(‘a’=10,’b’=20,’c’=30) > for (i in seq_along(mylist)){ + print(paste(i,names(mylist)[i],mylist[[i]])) + } [1] “1 a 10” [1] “2 … Read more