prop | R Documentation |
This function calculates the proportion of TRUE
values in a logical
vector.
prop(logical_vec, na.rm = FALSE)
logical_vec |
A logical vector. |
na.rm |
Logical. Should missing values be removed before calculation?
Behaves similar to |
The proportion of TRUE
values in the logical vector.
prop(c(TRUE, TRUE, FALSE, TRUE)) # Returns 0.75
prop(c(TRUE, FALSE, TRUE, FALSE, NA), na.rm = TRUE) # Returns 0.5
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.