Re: [Rd] seq_along and rep_along

2012-01-08 Thread robin hankin
hello Hadley thanks for this... > There are the flip operators of matlab, and rotating matrices/array by > multiples of 90 degrees. > arot() in the magic package does this (which is an operation frequently encountered in magic hypercubes) >> I'm always on the lookout for other array functiona

Re: [Rd] seq_along and rep_along

2012-01-08 Thread Hadley Wickham
> well put!  I would add, though, that t() generalizes to aperm(), > and the magic package contains  arev()  which is a generalization > of rev(). There are the flip operators of matlab, and rotating matrices/array by multiples of 90 degrees. > I'm always on the lookout for other array functional

Re: [Rd] seq_along and rep_along

2012-01-08 Thread robin hankin
hello folks [snip] > 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 > > -- well put! I would add, though, that t() generalizes to aperm(), and the magi

Re: [Rd] seq_along and rep_along

2012-01-06 Thread Hadley Wickham
> 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 stra

Re: [Rd] seq_along and rep_along

2012-01-06 Thread Duncan Murdoch
On 12-01-06 1:31 PM, Hadley Wickham wrote: Hi all, A couple of ideas for improving seq_along: * It would be really useful to have a second argument dim: seq_along(mtcars, 1) seq_along(mtcars, 2) # equivalent to seq_len(dim(mtcars)[1]) seq_len(dim(mtcars)[2]) I ofte