[R] adding counter to df by group
David Winsemius
dwinsemius at comcast.net
Thu May 4 01:23:05 CEST 2017
> 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
More information about the R-help
mailing list