how_many: Number of true values in logical array

View source: R/utils.R

how_manyR Documentation

Number of true values in logical array

Description

Return the count of the number of TRUE values from a vector as a convenience function.

Usage

how_many(.x, negate = FALSE)

Arguments

.x

A logical vector to count up true values from

negate

(FALSE) Should FALSE values be counted instead of TRUE

Details

Often we use a logical test across a vector to find out how many elements meet a specific criteria. For instance,

length(which(x>4))

This function is a convenience function to slightly simplify that syntax since it comes up so much. Using the example above,

how_many(x>4)

Value

The number of TRUE (or FALSE if negate) values in the vector .x

Examples

## Not run: 
how_many(iris$Sepal.Length>5)

## End(Not run)

steveneschrich/pgreportr documentation built on Jan. 13, 2025, 7:09 p.m.