Skip to contents

cut_by() converts numeric biomarker values to diagnostic categories using one or two cut-points. Values equal to a cut-point are assigned to the higher bin (i.e., positive or indeterminate), consistent with clinical thresholding practices.

Usage

cut_by(x, cutpts)

Arguments

x

A numeric vector of biomarker values.

cutpts

An object of class cutpts, see cutpts() for more details.

Value

A factor with levels "-", "~", "+".

Examples

# Using one cut-point
cut_by(x = 0:10, cutpts = cutpts(5))
#>  [1] - - - - - + + + + + +
#> Levels: - ~ +

# Using two cut-points
cut_by(x = 0:10, cutpts = cutpts(c(5, 7)))
#>  [1] - - - - - ~ ~ + + + +
#> Levels: - ~ +

# Using cutpoints from the curated table `cutpoints()`
cut_by(x = c(800, 1050, 1300), cutpts = cutpts("ab42-csf-elecsys-willemse2018"))
#> [1] + + -
#> Levels: - ~ +