Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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)
- df <- cbind( sum_accurrences = c("3", "5", "3"), df)
- df[str_split(df$animals, ";") %in% df$sentences, ]
- str_count(df$sentences, str_split(df$animals, ";"))
Add Comment
Please, Sign In to add comment