Skip to contents

get (proportion) percentage agreement of answers in a vector - 'agreement' to be defined by cutoff

Usage

prop_agree(x, cutoff = 1, restrict_level = NULL)

Arguments

x

a numeric vector

cutoff

a vector defining positive answers, default = 1 in a binary dataset

restrict_level

the minimum number of valid answers needed to display result, otherwise the answer is restricted and set to NA, default is NULL (no restriction)

Value

a numeric value between 0 - 1

Examples

# binary vector
vec <- c(0, 1, 1, 0, 0, 1, NA_real_, 1)
prop_agree(x = vec, cutoff = 1)
#> [1] 0.5714286

# with restriction - throws NA as not applicable
prop_agree(x = vec, cutoff = 1, restrict_level = 8)
#> [1] NA