Skip to contents

[Deprecated]

This function is deprecated. Please use slice_derivation() / derive_var_extreme_flag() to derive extreme flags and adjust the order argument.

Usage

derive_var_worst_flag(
  dataset,
  by_vars,
  order,
  new_var,
  param_var,
  analysis_var,
  worst_high,
  worst_low,
  check_type = "warning"
)

Arguments

dataset

Input dataset. Variables specified by by_vars, order, param_var, and analysis_var are expected.

by_vars

Grouping variables

Permitted Values: list of variables

order

Sort order. Used to determine maximal / minimal observation if they are not unique, see Details section for more information.

new_var

Variable to add to the dataset. It is set "Y" for the maximal / minimal observation of each group, see Details section for more information.

param_var

Variable with the parameter values for which the maximal / minimal value is calculated.

analysis_var

Variable with the measurement values for which the maximal / minimal value is calculated.

worst_high

Character with param_var values specifying the parameters referring to "high". Use character(0) if not required.

worst_low

Character with param_var values specifying the parameters referring to "low". Use character(0) if not required.

check_type

Check uniqueness?

If "warning" or "error" is specified, the specified message is issued if the observations of the input dataset are not unique with respect to the by variables and the order.

Default: "warning"

Permitted Values: "none", "warning", "error"

Value

The input dataset with the new flag variable added.

Details

For each group with respect to the variables specified by the by_vars parameter, the maximal / minimal observation of analysis_var is labeled in the new_var column as "Y", if its param_var is in worst_high / worst_low. Otherwise, it is assigned NA. If there is more than one such maximal / minimal observation, the first one with respect to the order specified by the order parameter is flagged. The direction of "worst" depends on the definition of worst for a specified parameters in the arguments worst_high / worst_low, i.e. for some parameters the highest value is the worst and for others the worst is the lowest value.