at-methods: Access elements from an object

Description Usage Arguments Details Value Examples

Description

Extracts a set of <key, value> pairs. For hashmaps mappings from

f: keys -> values,

exist so argument which is per default values (since these are going to be retrieved). For bimaps also

f: values -> keys,

mappings exist, such that which can also be keys if the keys from the object should be retrieved.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
at(obj, x, which = c("values", "keys"), ...)

## S4 method for signature 'bimap,vector,character'
at(obj, x, which = c("values", "keys"))

## S4 method for signature 'bimap,vector,missing'
at(obj, x)

## S4 method for signature 'unordered_map,vector,missing'
at(obj, x)

Arguments

obj

object to extract values from

x

the set of keys to match the values

which

choose either values if the values should get returned

...

other arguments or keys if the keys should get returned

Details

# datastructures: Implementation of core datastructures for R. # # Copyright (C) Simon Dirmeier # # This file is part of datastructures. # # datastructures is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # datastructures is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with datastructures. If not, see <http://www.gnu.org/licenses/>.

Value

returns extracted keys or values from obj

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
# access values from a hashmap
h_map <- hashmap("integer")
h_map[seq(2)] <- list(data.frame(a=rexp(3), b=rnorm(3)), environment())
h_map[1L]

# access values or keys from a bimap
b_map <- bimap("integer", "character")
b_map[seq(5)] <- letters[seq(5)]
at(b_map, c(1L, 3L))
at(b_map, c(1L, 3L), which="values")
at(b_map, c("a", "c"), which="keys")

# access values from a multimap
m_map <- multimap("integer")
m_map[c(seq(5), seq(5))] <- letters[seq(10)]
at(m_map, 1L)

datastructures documentation built on Aug. 10, 2020, 5:08 p.m.