library(stringr)
cat <- c("AA","AA","AA","Ee","Dd","Ee","Bb","Cc","Cc","Cc")
yyy <- table(cat)
# yyy
# AA Bb Cc Dd Ee
# 3 1 3 1 2
For table named yyy, the categories AA and Cc have the same frequency. The same is true for Bb and Dd. My intention is to give a name like AA|Cc for AA and Cc. By applying the same principle for other categories, how do I name and generate the following table? Thank you!
# AA|Cc Ee Bb|Dd
# 3 2 1