topc {cata}R Documentation

Apply top-c choices coding to a vector of scale data from a respondent

Description

Apply top-c choices coding to a vector of scale data from a respondent

Usage

topc(x, c = 2, coding = "B")

Arguments

x

input matrix

c

number of top choices considered to be 'success'; other choices are considered to be 'failure' and are coded 0

coding

"B" (default) codes all successes as 1; "N" codes all successes with their numeric coding

Value

matrix X with top-k coding applied

References

Castura, J.C., Meyners, M., Pohjanheimo, T., Varela, P., & Næs, T. (2023). An approach for clustering consumers by their top-box and top-choice responses. Journal of Sensory Studies, e12860. doi:10.1111/joss.12860

Examples

# Generate some data
set.seed(123)
X <- matrix(sample(1:9, 100, replace = TRUE), nrow = 5)

# apply top-2 choice (T2C) coding
apply(X, 1, topc)

[Package cata version 0.1.0.6 Index]