prob | R Documentation |
Convert an rvec of logical values (an rvec_lgl) into a vector of probabilities.
prob(x, na_rm = FALSE)
## S3 method for class 'rvec_lgl'
prob(x, na_rm = FALSE)
## S3 method for class 'logical'
prob(x, na_rm = FALSE)
x |
An object of class rvec_lgl. |
na_rm |
Whether to remove NAs before
calculating summaries. Default is |
prob()
is essentially just draws_mean()
with a different name. The proportion of
draws that are TRUE
is used as an estimate of the
underlying probability. The different name
can make the intent of the code clearer.
A logical vector with the same
length as x
.
draws_mean()
Means across draws. Gives
the same result as prob
when applied
to logical rvecs.
m <- rbind(c(FALSE, TRUE),
c(TRUE, TRUE),
c(FALSE, FALSE))
x <- rvec(m)
x
prob(x)
## logical rvec created on the fly
## through operations such as '>'
m <- rbind(c(-1, 1.3, 2),
c(2, 0.1, -1),
c(Inf, 0, -0.5))
y <- rvec(m)
y
prob(y > 0)
prob(y >= 0)
prob(y^2 > 0)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.