The values
method returns the values from a hash. It is
similar to h[[ keys(h) ]]
except that a named vector or list
is returned instead of a hash.
:
By default, the returned values are simplified by coercing to
a vector or matrix if possible; elements are named after the
corresponding key. If the values are of different types or of a
complex class than a named list is returned. Argument
simplify
can be used to control this behavior.
If a character vector of keys
is provided, only these keys
are returned. This also allows for returning values mulitple times
as in:
values(h, keys=c('a','a','b' ) )
This is now the preferred method for returning multiple values for
the same key.
The replacement method, values<-
can replace all the values or
simply those associated with the supplied keys
. Use of the
accessor '[' is almost always preferred.