inlist_cnt: inlist count function

View source: R/summary.R

inlist_cntR Documentation

inlist count function

Description

Works the same as inlist but returns the count of the match_vars matched instead of simply '0' or '1'. e.g. inlist_cnt(c("1, 2","2, 3, 4","0, 1","1, 9"),c(2,3,4)) would return 1, 3, 0, 0

Usage

inlist_cnt(
  srch_var,
  match_var,
  delimiter = ", ",
  threshold = 1,
  binary_return = FALSE
)

Arguments

srch_var

a vector of characters each a delimited list of numeric items, see inlist. This is common output to mutliple choice questions.

match_var

an atomic or vector or values to match against each element. for example if you wanted to know who selected options 1, 3, and 5 then this argument would be c(1, 3, 5)

delimiter

the delimiter used for the data. default is set to ", "

threshold

allows the user to set a threshold amount of attributes that must be met in order to be returned. This only works with binary return=TRUE. e.g. for the above example if threshold = 2 then the binary result would be 0, 1, 0, 0. default value is 1

binary_return

choose if the results returned are the counts (default) or a vector of 0/1. with threshold = 1, binary_return returns the same result as inlist. by increasing threshold the user can determine the reuqired amount of attributes to be '1' vs '0'

Examples

inlist_cnt_function()

clmacleod/highlandr documentation built on Oct. 11, 2023, 8:04 p.m.