count_val {cheapr}R Documentation

Count the number of occurrences of a value.

Description

This is a programmer's version of sum(x == value) to count the number of occurrences of a value without creating a potentially large logical vector.

Usage

count_val(x, value, recursive = TRUE)

Arguments

x

A vector, list, data frame or matrix.

value

A value with which to count the frequency of.

recursive

Should the function be applied recursively to lists?

Details

This is a generalisation of num_na() and as such the identity count_val(x, NA) == num_na(x) will always hold.

Value

A count of the number of times value appears in x.


[Package cheapr version 0.9.2 Index]