Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201839

how can I count the serial number of a vector inside the lapply?

$
0
0

I have a big vactor (3GB) to process thru lapply, and I would like to know how much it has proceeded. It is easier if I can identify which element it is, but what if I can't?

In the for loop, I may assign a counter inside the loop, but how should I do to set a counter inside lapply?

X <- LETTERS[1:26]

lapply(X, function(a) {
  cat(paste0(which(X == a), "\r")
  print(a)
})

Many thanks.


Viewing all articles
Browse latest Browse all 201839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>