.set {hash}R Documentation

assign key-value pair(s) to a hash

Description

.set is an internal method for assigning key-value pairs to a hash. Normally, there is no need to use this function. Convenient access is provided by: \$, [ and [[ and their corresponding replacement methods.

.set takes a pair of vectors. The first is coerced to valid hash keys. The second servers as values.

Usage

.set(hash, keys, values )

Arguments

hash An hash object on which to set the key-value pair(s)
keys A vector of keys that will be coerced to valid key-value pairs. See Details.
values A vector of values. See details.

Details

.set sets zero or more key-value pairs. If the key(s) already exist, existing values are silently clobbered. Otherwise, a new value is saved for each key. Keys and values are determine by the length of these vectors. If:

... keys and values are the same length, key-value pairs are added to the hash pairwise.

... keys is a vector of length 1, then this key is assigned the entire values vector.

... values is a vector of length 1, each key of keys is assigned the value given by values

... keys and values are of different lengths, both greater than one, then the assignment is considered ambiguous and an error is thrown.

Value

.set exists solely for its side-effects. An invisible NULL is returned.

Author(s)

Christopher Brown

See Also

See also hash, environment


[Package hash version 0.23 Index]