filter_list: Filter list by name/value

Description Usage Arguments NOTE Examples

View source: R/filter_list.R

Description

Filters list (at top-level only) by name or value.

Usage

1

Arguments

list

a list

name

a name to search for within a list; can be anything that can appear as a name in a list

value

a value to search for within a list

NOTE

filter_list() is useful for returning matches of a name or value. Currently, it will only search the top-level in a list and matches must be exact. Unlike purrr::pluck(), filter_list() will return all matches (not just the first match).

Examples

1
2
3
4
5
6
l <- list(this = 1, that = 2, that = 3, final = 2)

purrr::pluck(l, "that") # returns only first match
filter_list(l, "that") # returns all matches

filter_list(l, value = 2)

allenbaron/JABmisc documentation built on July 4, 2021, 9:56 a.m.