dize r aldığım bir dataframe 's'grep birden desen ve saymak kaç ben bir dize örneğin</p> <p>, içinde eşleştirildiyse kaç sayımı ile ilgili bir soru var
index string
1 'I have first and second'
2 'I have first'
3 'I have second and first and third'
ve
: toMatch adlı bir eşleşme düzeni vektörtoMatch <- c('first', 'second', 'third')
istediğim nihai sonuç gibidir
string count
'I have first and second' 2
'I have first' 1
'I have second and first and third' 3
şimdi sadece
grepl(paste(toMatch, collapse = "|"), s$string)
o toMatch içinde elemanın herhangi maçları hangi dize beni dönecektir kullanabilirsiniz, ancak nasıl eşleştirildiği kaç eleman bilebilirim?
Herhangi bir yardım için teşekkür ederiz! Şimdiden teşekkürler! Daha hızlı olabilir
teşekkürler! İşe yarıyor! ^^ –