powered by
Computes the marginal probability \(P(X = 1)\) for a binary vector `x`, ignoring missing values.
prob(x)
A numeric scalar giving the proportion of entries equal to 1 among the non-missing values of `x`.
A numeric or logical vector coded as 0/1 (or `FALSE`/`TRUE`). Values other than 0, 1, `FALSE`, `TRUE`, or `NA` will be ignored.
prob(c(0, 1, 1, 0, 1))
Run the code above in your browser using DataLab