seq_along function

So what does seq_along actually do in a for loop?

seq_along() generates a sequence the same length of the argument passed, and in the context of a for loop is used to more easily generate the index to iterate over, see this example.

#> [1] "a" "b" "c" "d" "e"

#> [1] 1 2 3 4 5

for (i in seq_along(letters[1:5])) {

Created on 2019-09-07 by the reprex package (v0.3.0.9000)

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.