R - count matches between characters of one string and another, no replacement

后端 未结 2 849
生来不讨喜
生来不讨喜 2020-12-31 10:42

I have a keyword (e.g. \'green\') and some text (\"I do not like them Sam I Am!\").

I\'d like to see how many of the characters in the keyword (\'g\', \'r\',

2条回答
  •  死守一世寂寞
    2020-12-31 11:27

    Perhaps you are looking to find the UNIQUE components of your keyword? Try:

    keyword <- unique(strsplit('greeen','')[[1]])
    

提交回复
热议问题