Skip to contents

Accepts a data frame containing raw data and calculates performance indices using a user-defined function.

Usage

preproc_data(
  data,
  fn,
  ...,
  col_raw_parsed = "raw_parsed",
  pivot_results = TRUE,
  pivot_names_to = "index_name",
  pivot_values_to = "score"
)

Arguments

data

A data.frame contains raw data.

fn

This can be a function or formula. See rlang::as_function() for more details.

...

Additional arguments passed to fn.

col_raw_parsed

The column name in which stores user's raw data in format of a list of data.frames.

pivot_results

Whether to pivot the calculated indices. If TRUE, the calculated indices are pivoted into long format, with each index name stored in the column of pivot_names_to, and each index value stored in the column of pivot_values_to. If FALSE, the calculated indices are stored in the same format as returned by fn.

pivot_names_to, pivot_values_to

The column names used to store index names and values if pivot_results is TRUE. See tidyr::pivot_longer() for more details.

Value

A data.frame contains the calculated indices.

Details

Observations with empty raw data (empty vector, e.g. NULL, in col_raw_parsed column) are removed before calculating indices. If no observations left after removing, a warning is signaled and NULL is returned.