I work with combinign unique values and if i read your comment right :
the point here is start from a "tabular dataframe" (2 columns) and finish in a dataframe with the different values (b1,b2,b3) per unique value in the first column of tabular dataframe (B)
====
Alternative 1: You can merge in the same df of 2 columns with 3rd contianing unique values by grouping and summarizing.
s <- data.frame(V1=c("A","A","B","B","B","C"), V2=c("a1","a2","b1","b2","b3","c1"))
s%>%
group_by(V1)%>%
summarise(
Values = paste0('**',V1,'**'," ",paste(unique(V2),collapse = ", "))
)
yields :
V1 Values
<chr> <chr>
1 A **A** a1, a2
2 A **A** a1, a2
3 B **B** b1, b2, b3
4 B **B** b1, b2, b3
5 B **B** b1, b2, b3
6 C **C** c1
You can remove duplicates with %>%unique()
to get
V1 Values
<chr> <chr>
1 A **A** a1, a2
2 B **B** b1, b2, b3
3 C **C** c1
Let me know if this is what you are looking for though Its exactly same input you posted and output is same as well (but in a single column)