答案 0 :(得分:2)
# Data
df <- read.delim(textConnection('Category
{A}
{B}
{C}
{A,B}
{A,C}
{C}
{C,A,B}
{A}
{A,C}'))
# Slice, keeping only rows in 'Category' containing character 'A'
subset(df, grepl('A', Category))
Category
1 {A}
4 {A,B}
5 {A,C}
7 {C,A,B}
8 {A}
9 {A,C}
答案 1 :(得分:0)
grep应该派上用场
DT[grep('A',DT$Category,ignore.case = FALSE),]