calc_max_precision: Calculate the mode value at maximum precision

View source: R/calc_max_precision.R

calc_max_precisionR Documentation

Calculate the mode value at maximum precision

Description

This function determines the mode of a variable 'x', filtered to entries with the maximum value of a specified precision vector 'precision_var'. It optionally resolves ties using one or two additional vectors for tie-breaking.

Usage

calc_max_precision(x, precision_var, tie_break = NULL, second_tie_break = NULL)

Arguments

x

A vector of values for which to find the mode.

precision_var

A vector of precision values corresponding to 'x', used to filter to maximum values.

tie_break

Optional; a vector used as the first tie-break criterion.

second_tie_break

Optional; a vector used as the second tie-break criterion.

Value

Returns the mode of 'x' for entries with maximum 'precision_var' value. If no valid entries exist, returns an empty string.

Examples

x = c("apple", "apple", "banana", "banana")
precision_var = c(1, 2, 1, 2)
tie_break = c(1, 2, 1, 2)
second_tie_break = c(1, 1, 2, 1)
calc_max_precision(x, precision_var, tie_break, second_tie_break)

eventreport documentation built on March 11, 2026, 1:07 a.m.