I'm trying to do something similar as in this post here: Extract rows for the first occurrence of a variable in a data frame but extract all occurrences, not just the first.
Here is a simplified example: I have this data frame called toDrop
Gene Taxa
123 A
327 B
445 D
557 A
789 E
123 B
557 C
Here's my code that uses match and thus returns the first match only. I'm running this inside a loop so modifying things here for simplicity.
Gene <- c("123", "327", "445", "557", "789", "123", "557")
Taxa <- c("A", "B", "D", "A", "E", "B", "C")
toDrop <- data.frame(Gene, Taxa)
Temp <- list()
geneNameTemp <- "123"
toDrop[match(geneNameTemp, toDrop$Gene), 2] -> Temp
In this example, Temp should return a list of "A" and "B" I think I need to use lapply as in this post but can't figure it out from that example. Thanks for the help.