Guest User

Untitled

a guest
Jan 20th, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. df = data.frame(animals = c("cat; dog; bird", "dog; bird", "bird"), sentences = c("the cat is brown; the dog is barking; the bird is green and blue","the dog is black; the bird is yellow and blue", "the bird is blue"), stringsAsFactors = F)
  2.  
  3. df <- cbind( sum_accurrences = c("3", "5", "3"), df)
  4.  
  5. df[str_split(df$animals, ";") %in% df$sentences, ]
  6.  
  7. str_count(df$sentences, str_split(df$animals, ";"))
Add Comment
Please, Sign In to add comment