I would like to get a list of top level elements that contain a particular sub-element. Suppose I have a nested list:
v <- list(A=list('a', 'b', 'c'), B=list('c','d','e'), C=list('d'))
I am trying to get the list of all top-level elements that have a particular sub element:
- if I am looking for 'c' I would expect to get ('A', 'B').
- if I am looking for 'd' I would expect to get ('B', 'C')
NOTE: prefer a base-R solution but would be interesting to see others