Sequence along a dimension
seq_along_dim(x, which_dim) seq_along_rows(x) seq_along_cols(x)
x | a dataframe, array or vector. For |
---|---|
which_dim | a scalar integer or character string, specifying which dimension to generate a sequence for. Negative numbers count from the back. |
a vector of integers 1:nrow(x), safe for use in for
loops and
vectorized equivalents.
#> mpg cyl disp hp drat wt qsec vs am gear carb #> Mazda RX4 21 6 160 110 3.9 2.62 16.46 0 1 4 4 #> mpg cyl disp hp drat wt qsec vs am gear carb #> Mazda RX4 Wag 21 6 160 110 3.9 2.875 17.02 0 1 4 4 #> mpg cyl disp hp drat wt qsec vs am gear carb #> Datsun 710 22.8 4 108 93 3.85 2.32 18.61 1 1 4 1 #> mpg cyl disp hp drat wt qsec vs am gear carb #> Hornet 4 Drive 21.4 6 258 110 3.08 3.215 19.44 1 0 3 1#> [1] TRUE