prop {checkthat} | R Documentation |
Calculate Proportion of TRUE Values in a Logical Vector
Description
This function calculates the proportion of TRUE
values in a logical
vector.
Usage
prop(logical_vec, na.rm = FALSE)
Arguments
logical_vec |
A logical vector. |
na.rm |
Logical. Should missing values be removed before calculation?
Behaves similar to |
Value
The proportion of TRUE
values in the logical vector.
Examples
prop(c(TRUE, TRUE, FALSE, TRUE)) # Returns 0.75
prop(c(TRUE, FALSE, TRUE, FALSE, NA), na.rm = TRUE) # Returns 0.5
[Package checkthat version 0.1.0 Index]