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
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 the probability of a female (Id) changes if she had
given birth to a pup in the previous year. So my dataframe consists of the
column Id, year (2003-2007 fo
4 matches
Mail list logo