how_many | R Documentation |
Return the count of the number of TRUE values from a vector as a convenience function.
how_many(.x, negate = FALSE)
.x |
A logical vector to count up true values from |
negate |
(FALSE) Should FALSE values be counted instead of TRUE |
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)
The number of TRUE (or FALSE if negate
) values in the vector .x
## Not run:
how_many(iris$Sepal.Length>5)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.