inlist: inlist function

View source: R/summary.R

inlistR Documentation

inlist function

Description

base building function for inlist suite but recommend using inlist2 as it is a more advanced function. This function determines if the character of interest (i.e. the category) has been checked in mutiple choice questions bound as vectors of delimited numeric characters e.g. inlist(c("1, 2","2, 3, 4","0, 1","1, 9"),1) would return 1, 0, 1, 1 as it searched for '1' in a list and only the 1st, 3rd, and 4th elements contained '1'

Usage

inlist(srch_var, match_var, delimiter = ", ")

Arguments

srch_var

a vector of characters each a delimited list of items. for example c("1, 2, 3", "4, 5", "1, 4, 5"). This is common output to mutliple choice questions. in the example given there would be 3 records, the first having selected options 1, 2, and 3, the second options 4 and 5, and the third options 1, 4, and 5

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 ", "

Examples

inlist_function()

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