samedi 12 août 2017

Suggestion for finding patterns and replacing partitions in R

n = c(1, 2, 3, 3, 3, 3, 1, 1, 2, 3, 2, 1, 2, 2, 2, 1, 1, 1, 2, 1, 3, 2, 3)

I want to divide/split them into segments with every 3 integers and finds the pattern of each segment(A: all different, B: two identical, and C: all identical).

I did the partitioning with

par = split(n, ceiling(seq_along(n)/3))

but i am stuck with getting the patterns, any suggestion? I want to get something like

newn [1] A C B A C C A

Aucun commentaire:

Enregistrer un commentaire