Learn R Programming

Dict (version 0.6)

map_dict: Map, filter, collect on keys and values of the dictionary

Description

map_dict calls a function on each (key, value) pair and builds a dictionary from the transformed input (see map in package purrr). keep_dict and discard_dict keep and discard elements based on the return value of the predicate function (see keep and discard in package purrr). compact_dict returns a dictionary with all the NULL values removed.

Usage

map_dict(dict, .f, ...)
keep_dict(dict, .p, ...)
discard_dict(dict, .p, ...)
compact_dict(dict)

Arguments

dict
A dictionary
.f
A function, formula or character vector.
.p
A predicate function returning a logical value. If a function, it is called with two arguments, the key and the value. If a formula, .x corresponds to the key and .y to the value. If a character vector, it will return the values corresponding to the keys in the vector.

Value

For map_dict, a dictionary with the same keys as dict, and values given by the return value of .f. For keep_dict, discard_dict, and compact_dict, a dictionary containing the entries that passed the filter.