code.topk {cata}R Documentation

Apply top-k box coding to scale data

Description

Apply top-k box coding to scale data. Using defaults give top-2 box (T2B) coding.

Usage

code.topk(X, zero.below = 8, one.above = 7)

Arguments

X

input matrix

zero.below

default is 8; values below this numeric threshold will be coded 0; use NULL if there is no such threshold

one.above

default is 7; values above this numeric threshold will be coded 1; use NULL if there is no such threshold

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 box (T2B) coding
code.topk(X, zero.below = 8, one.above = 7)

[Package cata version 0.1.0.6 Index]