x <- c('aa', 'ab', 'ac', 'bb', 'bc')
grep('a', x, value=TRUE)
[1] "aa" "ab" "ac"
However, When I applied to my example, it is not working properly.
> logit_coef$label
"(Intercept)" "changer" "changem" "revenue"
"mou" "overage" "roam" "conference" "months" "uniqsubs" "custcare"
"retcalls" "dropvce" "eqpdays" "refurb|yes" "smartphone|yes"
"highcreditr|yes" "occupation|student" "occupation|retired"
grep('|', logit_coef$label, value=TRUE)
It gives me all of the columns, I only want to name of columns contain '|'
"smartphone|yes" "highcreditr|yes" "occupation|student"
"occupation|retired" That is the result I want