powered by
Count how often elements occur in a container.
count(x, values)
Returns a vector of the same length as values, denoting for each value how often it occurs.
values
A CppSet, CppUnorderedSet, CppMultiset, CppUnorderedMultiset, CppMap, CppUnorderedMap, CppMultimap, or CppUnorderedMultimap object.
A vector of elements to check. Refers to keys in the case of CppMap, CppUnorderedMap, CppMultimap, and CppUnorderedMultimap objects.
[, ==, at, contains, size, empty.
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
Run the code above in your browser using DataLab