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# M1M2 NN2#1 4 A 1 470#211B135 114#311B168 112#411B172 116#511B299 1 9#611B300 114#711B301 114#816B335 124#916B336 115#10 16B364 132#11 16B566 1 193#12 16B567 176#13 16B590 110#14 16B591 1 9what I am looking for to do, is to check the M1 and based on M1 highlight the M2I want to evaluate the sequential based on similar values of M1in this example # M1M2NN2#1 4A 1470so it is only one and I don't need to highlight it #211B135 114#311B168 112#411B172 116#511B299* 1 9#611B300* 114#711B301* 114in 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 #816B335* 124#916B336* 115#10 16B364132#11 16B566**1 193#12 16B567**176#13 16B590***110#14 16B591***1 9in 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

In the last section you B335* and B336* but in your example there is no B336. Is that a typo?

**2019年04月22日05分39秒**

PierreLafortune thanks it was a typo, I corrected it

**2019年04月22日05分39秒**

can we get the same structure output as mentioned in the question ?

**2019年04月22日05分39秒**

that is definitely very good but with a small problem. it does not refresh putting the star on each section , so it is growing like crazy. lets say in that example we have 3 section 4, 11 and 16, I want each time start over won't end up with so many stars , you know what i mean?

**2019年04月22日05分39秒**

I see, I edited, just made it into a function and used group_by(M1) to apply the highlight function to each section

**2019年04月22日05分39秒**

Look at str(summ) it is a data.table. Try summ <- as.data.frame(summ)

**2019年04月22日05分39秒**

Your methods are creating big problems for you down the line. Why would you add stars to numbers as you did in this question. You cannot do any mathematical or organizational functions with them that way. In the other question you create a useless link like 3-4? That is not a programmer's mindset. You are using R to create marks and ticks as you would with a pen and pencil. It is better to use the language in a way that exploits its strengths than struggle with convoluted workarounds left and right.

**2019年04月22日05分39秒**

- how to rearrange an order of matches between two data frames
- How to sort a dataframe by multiple column(s)
- subsetting columns based on columns containing duplicates
- Looping subsets in plm
- how to make a bar plot for a list of dataframes?
- how to make a network of user in a dataframe?
- “minimum count is not zero” error for zero inflated model
- Matplot not plotting dataset
- plot graphs in R while showing all the x axis values
- Add secondary X-axis with facets
- R error: “invalid type (NULL) for variable”

ADS