Learn R Programming

eventreport (version 0.1.1)

calc_max_precision: 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)

Value

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

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.

Examples

Run this code
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)

Run the code above in your browser using DataLab