Next time if dd is your data frame display dput(dd) so we know exactly
what you have.
>From your output I guessed it was numeric but the behavior of the 0/1
column that you describe is consistent with it being a factor rather
than numeric. Try
dd$of <- as.numeric(levels(dd$of)[dd$of])
or equiva
thanks, it works! well, now it shows 1s instead of 0s and 2s instead of 1s,
which fine with me...but could you explain me what this function actually
does?
Gabor Grothendieck wrote:
>
> Iff dd is your data frame then:
>
> dd$prev <- ave(dd$of, dd$Id, FUN = function(x) c(NA, head(x, -1)))
>
>
Iff dd is your data frame then:
dd$prev <- ave(dd$of, dd$Id, FUN = function(x) c(NA, head(x, -1)))
On Wed, Oct 21, 2009 at 2:55 AM, clion wrote:
>
> Dear Rlers,
> in the following dataset I would like to insert a new column that refers to
> the data of the previous row.
> My question is whether
3 matches
Mail list logo