使用grepl并不能达到我想要的效果

时间:2018-05-18 01:36:01

标签: r grepl

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

0 个答案:

没有答案