seq_along_dim: Sequence along a dimension

Description Usage Arguments Value Examples

View source: R/seq_along.R

Description

Sequence along a dimension

Usage

1
2
3
4
5

Arguments

x

a dataframe, array or vector. For seq_along_rows, and seq_along_cols sequence along the first and last dimensions, respectively. Atomic vectors are treated as 1 dimensional arrays (i.e., seq_along_rows is equivalent to seq_along when x is an atomic vector or list).

which_dim

a scalar integer or character string, specifying which dimension to generate a sequence for. Negative numbers count from the back.

Value

a vector of integers 1:nrow(x), safe for use in for loops and vectorized equivalents.

Examples

1
2
3
4
5
for (r in seq_along_rows(mtcars[1:4,]))
  print(mtcars[r,])

x <- 1:3
identical(seq_along_rows(x), seq_along(x))

listarrays documentation built on March 26, 2020, 6:10 p.m.