My data is
df <- structure(list(M1 = c(4L, 11L, 11L, 11L, 11L, 11L, 11L, 16L,
16L, 16L, 16L, 16L, 16L, 16L), M2 = structure(c(14L, 1L, 2L,
3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L), .Label = c(" B135",
" B168", " B172", " B299", " B300", " B301", " B335", " B336",
" B364", " B566", " B567", " B590", " B591", "A"), class = "factor"),
N = c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L), N2 = c(470L, 14L, 12L, 16L, 9L, 14L, 14L, 24L, 15L,
32L, 193L, 76L, 10L, 9L)), .Names = c("M1", "M2", "N", "N2"
), class = "data.frame", row.names = c(NA, -14L))
The data looks like this
>df
# M1 M2 N N2
#1 4 A 1 470
#2 11 B135 1 14
#3 11 B168 1 12
#4 11 B172 1 16
#5 11 B299 1 9
#6 11 B300 1 14
#7 11 B301 1 14
#8 16 B335 1 24
#9 16 B336 1 15
#10 16 B364 1 32
#11 16 B566 1 193
#12 16 B567 1 76
#13 16 B590 1 10
#14 16 B591 1 9
what I am looking for to do, is to check the M1 and based on M1 highlight the M2 I want to evaluate the sequential based on similar values of M1 in this example
# M1 M2 N N2
#1 4 A 1 470
so it is only one and I don't need to highlight it
#2 11 B135 1 14
#3 11 B168 1 12
#4 11 B172 1 16
#5 11 B299* 1 9
#6 11 B300* 1 14
#7 11 B301* 1 14
in this section (which all data from the M1 is 11) B299, B300 and B301 are sequential (repeated after each other) so I want to highlight it with for example a star
#8 16 B335* 1 24
#9 16 B336* 1 15
#10 16 B364 1 32
#11 16 B566** 1 193
#12 16 B567** 1 76
#13 16 B590*** 1 10
#14 16 B591*** 1 9
in this section( all values from M1 is 16) B335 and B336 are sequential so I highlight them with one star then B566 and B567 are also sequential with ** star because they are different from the first one , the same for the third sequential group etc