I have an empty column designated for categorising entries in my data frame. Categories are not exclusive, i.e. one entry can have multiple categories.
animals categories
1 monkey
2 humpback whale
3 river trout
4 seagull
The categories column should have categories based on the animal's properties. I know the properties based on vectors. The elements in the vectors aren't necessarily a perfect match.
mammals <- c("whale", "monkey", "dog")
swimming <- c("whale", "trout", "dolphin")
How do I get the following result, ideally without looping?
animals categories
1 monkey mammal
2 humpback whale mammal,swimming
3 river trout swimming
4 seagull