Message-ID: <CABdHhvHPOjrKBKimuJ9F++YcXXL2y9Mn+LghAHo8k1qSc1gTDg@mail.gmail.com>
Date: 2012-01-06T19:52:22Z
From: Hadley Wickham
Subject: seq_along and rep_along
In-Reply-To: <4F074B28.8020307@gmail.com>
> I don't see the benefit of seq_along(mtcars, 1) versus seq_len(nrow(df)) in
> readability.
I like it because:
* it reads nicely: I want a sequence along this structure in that direction
* it's more consistent: for(i in seq_along(x)) -> for(row in
seq_along(mtcars, 1))
* it generalised in a straightforward way to arrays
I don't think it's a huge improvement, but it is frustrating when base
functionality only works with vectors, not matrices, or arrays. It
would be more compelling if (e.g.) t and rev also had dimension
arguments.
Hadley
--
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University
http://had.co.nz/