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

Description Usage Arguments Value

View source: R/dict.r

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

1
2
3
4
5
6
7

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.


stefano-meschiari/dict documentation built on May 30, 2019, 10:44 a.m.