Find phrases containing some base phrase


/ Published in: R
Save to your folder(s)

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


Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.