I do a lot of batch/parametric data analysis and have found that lists of lists that define/configure the processing tasks and hold the results next to the config that produced them are maximally flexible and convenient. This leads naturally to the condition where I want to filter my config/results using arbitrary boolean criteria applied to their values. I’m looking for or planning to implement something that operates in a manner similar to
purrr::keep, but evaluates NSEs against the list elements and returns a subset of the original list containing the matches (i.e. rather than operating on rows in the context of tbls).
!!, etc. I think I see a path to the implementation, but there is so much in
purrr and elsewhere that is similar that I half expect to stumble upon a pre-existing implementation or a discussion involving similar capabilities. After searching I haven’t quite found it. So the question is how to implement the following hypothetical
config = list( list(a=1), list(a=3, b=1), list(b=2)) config %>% list_filter( a == 1 ) # returns config config %>% list_filter( ! is.null(b) ) # returns config[2:3] config %>% list_filter( ! is.null(a) ) # returns config[1:2] config %>% list_filter( a > 1 & b <= 2 ) # returns config