Dear Jens,
Here is one way:

x$sequ <- ave(x$dv, paste(x$block, x$trial, sep=""), FUN = function(x)
seq(length(x)) )
x

where x is your data.

HTH,

Jorge


On Fri, Jul 10, 2009 at 9:27 AM, Jens Bölte <[email protected]>wrote:

> Hello,
>
> I have a data frame of the following form
>
> block trial dv
> 1 1 10
> 1 1 11
> 1 1  9
> 1 2 12
> 1 2  9
> 1 3 12
> 1 3 13
> 1 3 14
> 1 3 15
> 1 4 12
> 1 4 11
> 1 4 10
> 1 4  9
> 1 4 11
>
> and need to number the rows consecutively in the following manner
>
> block trial dv sequ
> 1 1 10 1
> 1 1 11 2
> 1 1  9 3
> 1 2 12 1
> 1 2  9 2
> 1 3 12 1
> 1 3 13 2
> 1 3 14 3
> 1 3 15 4
> 1 4 12 1
> 1 4 11 2
> 1 4 10 3
> 1 4  9 4
> 1 4 11 5
>
> Any idea how to solve this problem? I tried but did not succeed :-(
>
> Best Jens Bölte
>
> ______________________________________________
> [email protected] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>

        [[alternative HTML version deleted]]

______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to