From ggrothendieck at gmail.com  Tue Apr  3 06:40:03 2007
From: ggrothendieck at gmail.com (Gabor Grothendieck)
Date: Tue, 3 Apr 2007 00:40:03 -0400
Subject: [Rd] Behavior of seq_along (was: Create a new var reflecting the
	order of subjects in existing var)
Message-ID: <971536df0704022140x37d61904l1ec7f5dbc0761052@mail.gmail.com>

I am moving this from r-help to r-devel.  Based on offline communications
with Jim, suppose dat is defined as follows:

set.seed(123)
dat <- data.frame(ID= c(rep(1,2),rep(2,3), rep(3,3), rep(4,4),
   rep(5,5)), var1 =rnorm(17, 35,2), var2=runif(17,0,1))

# Then this ave call works as expected:

ave(dat$ID, dat$ID, FUN = function(x) seq_along(x))

# but this apparently identical calculation gives an error:

ave(dat$ID, dat$ID, FUN = seq_along)

The only difference between the two calls is that the first one
uses seq_along and the second uses function(x) seq_along(x)
in its place.

Does anyone know why the second gives an error?  Is this
a bug in the implementation of seq_along?



[Rd] Behavior of seq_along (was: Create a new var reflecting the order of subjects in existing var)
Gabor Grothendieck