x <- c('aa', 'ab', 'ac', 'bb', 'bc')
grep('a', x, value=TRUE)
[1] "aa" "ab" "ac"
但是,当我应用于我的示例时,它无法正常工作。
> 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)
它为我提供了所有列,我只希望列的名称包含&#39; |&#39;
"smartphone|yes" "highcreditr|yes" "occupation|student"
"occupation|retired" That is the result I want