count {cppcontainers} | R Documentation |
Count element frequency
Description
Count how often elements occur in a container.
Usage
count(x, values)
Arguments
x |
A CppSet, CppUnorderedSet, CppMultiset, CppUnorderedMultiset, CppMap, CppUnorderedMap, CppMultimap, or CppUnorderedMultimap object. |
values |
A vector of elements to check. Refers to keys in the case of CppMap, CppUnorderedMap, CppMultimap, and CppUnorderedMultimap objects. |
Value
Returns a vector of the same length as values
, denoting for each value how often it occurs.
See Also
[, ==, at, contains, size, empty.
Examples
s <- cpp_set(4:9)
s
# 4 5 6 7 8 9
count(s, 9:11)
# [1] 1 0 0
m <- cpp_map(c("hello", "there"), c(1.2, 1.3))
m
# ["hello",1.2] ["there",1.3]
count(m, c("hello", "world"))
# [1] 1 0
[Package cppcontainers version 1.0.0 Index]