Posted By

mjaniec on 04/17/11


Tagged

compare strings phrases


Versions (?)

Find phrases containing some base phrase


 / Published in: R
 

ElementsTable contains 1. phrases, 2. frequency of a given phrase

  1. FindContaining <- function(Element,ElementsTable) {
  2.  
  3. list <- matrix(,nrow(ElementsTable),2)
  4. j <- 0
  5. for (i in 1:nrow(ElementsTable)) {
  6. if (Element != ElementsTable[i,2]) {
  7. if ( grepl(Element,ElementsTable[i,2]) ) {
  8. j <- j+1
  9. list[j,1] <- ElementsTable[i,1]
  10. list[j,2] <- ElementsTable[i,2]
  11. }
  12. }
  13. }
  14.  
  15. list
  16. }

Report this snippet  

You need to login to post a comment.