Generate a multiple response vector
Source:R/FUNCTIONS_GENERATE_DATA.R
generate_multiple_response_vector.RdCreates a character vector where each element contains a comma-separated string of randomly sampled categories, simulating multiple response survey data.
Arguments
- responses
Integer or character vector. The pool of unique response categories to sample from. A single number
nmeans the categories1:n(e.g.responses = 4is the same as1:4). Default is1:4.- responded
Integer vector. Controls how many categories are selected per observation — one value is sampled from this vector at each iteration. A single number
kmeans "up tok": each observation gets a random number of categories between 1 andk(e.g.responded = 3gives 1, 2 or 3 categories). The values should not exceed the number of categories inresponses. Default is1:4.- length
Integer. Number of observations to generate. Default is
10.