Skip to contents

get number of agreement answers (defined by a cutoff) in a vector

Usage

n_agree(x, cutoff = 1)

Arguments

x

a numeric/integer vector

cutoff

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

Value

a numeric value

Examples

# usage with dichotomized vector
vec <- c(0, 0, 1, 1, 1)
n_agree(vec)
#> [1] 3

# usage with non-dichotomized vector:
vec <- c(1, 2, 3, 4, 3, 3, 4, 3, 4, 4, NA)
# you need to change the cutoff
n_agree(vec, cutoff = c(3,4))
#> [1] 8