entries: Converts a dictionary to a list of key/value pairs

Description Usage Arguments Value Examples

View source: R/dict.r

Description

Converts a dictionary into a list of entries containing key/value pairs, of the form list(entry(key = key1, value = value1), entry(key = key2, value = value2), ...). Each element of the list is a list containing a key element and a value element, created using the entry function. A list of entries can be collected back into a dictionary using the collect function.

Usage

1

Arguments

dict

a dictionary

Value

a list containing lists with two items, key and value, for each entry in the dictionary.

Examples

1
2
3
4
5
6
7
solar_system <- dict(Mercury = 0.387, Venus = 0.723, Earth = 1, Mars = 1.524)
for (e in entries(solar_system))
   cat('The distance between planet', e$key, ' and the Sun is', e$value, ' AU.\n')

inner_solar_system <- entries(solar_system) %>%
             keep(function(e) e$value <= 1) %>%
             collect()

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