[R] adding counter to df by group

David Winsemius
2017-05-03T23:23:05Z

> On May 3, 2017, at 11:24 AM, Davide Piffer <pifferdavide at
gmail.com> wrote:
>

You should look at this result more closely. Its length is not the same length
as the number of rows of the target of the attempted assignment.

> unlist(miniblock_cong)

You might try:

red_congruent$miniblock <- ave( red_congruent$subject_nr,
red_congruent$subject_nr, FUN=seq_along)

`ave` is very useful for delivering vectors with length equal to nrow of a
dataframe. Do remember to name the FUN parameter (although I still usually
forget).

--

David Winsemius
Alameda, CA, USA