dict: Create a dictionary

Description Usage Arguments Value See Also Examples

View source: R/dict.R

Description

Returns a dictionary in which numbers and string (including vectors of each) can be used as keys, and any R object can be used as value.

Usage

1
dict(init_keys = NULL, init_values = NULL)

Arguments

init_keys

Optional list of keys for initialization

init_values

Optional list of values for initialization

Value

A dictionary object that can be used to assign and extra values using either the [[ ]] operator or member functions accessed via $.

See Also

numvecdict

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
# create new dictionary
d <- dict()

# assign an item whose key is c(2:3)
d[[ c(2,3) ]] <- "Test"

# retrieve the element
d[[ c(2,3) ]]

# get will return NULL if the key is not in the dictionary
# (but you can also set the second argument to specify the default value)
d$get("?")

mkuhn/dict documentation built on May 23, 2019, 2:03 a.m.