I made a nested list like the one below.
group1 <- list(color = c("red", "green", "blue"),taste = c("sweet", "sour"))
group2 <- list(color = c("orange","purple","yellow"),taste = c("tan", "salt"))
nestedlist <- list(group1, group2)
now from this "nested list", i want to find out the which group an element belongs and which list element it belongs. Pardon my lack of understanding with list structure.
For example
test <- c("red", "tan")
given test i want the return of "color" "group1" and "taste" "group2"..
Is there any function to do this? I struggle with lists often. any help would be appreciated
nestedlist <- list(g1 = group1, g2 = group2)instead ofnestedlist <- list(group1, group2)? This way, you can just dounlist(nestedlist)and search on that.nestedlist <- list(g2.g1 = group1, g2 = group2)for instance.