This function applies weight conversion factors to the HCES data based on the conversion factors dataframe. It merges the HCES data and conversion factors dataframe on the `measure_id` column, and calculates the weight in kg for each food item using the conversion factor and consumption quantity. The resulting dataframe contains the original HCES data with additional columns for the conversion factor and weight in kg.
Usage
apply_wght_conv_fct(
hces_df,
conv_fct_df,
factor_col = "factor",
measure_id_col = "measure_id",
wt_kg_col = "wt_kg",
cons_qnty_col = "cons_quant",
allowDuplicates = FALSE
)
Arguments
- hces_df
A dataframe containing the HCES data.
- conv_fct_df
A dataframe containing the conversion factors.
- factor_col
The name of the column in `conv_fct_df` containing the conversion factors.
- measure_id_col
The name of the column in both dataframes containing the measure IDs.
- wt_kg_col
The name of the column to store the weight in kg.
- cons_qnty_col
The name of the column in `hces_df` containing the consumption quantity.
- allowDuplicates
A logical value indicating whether to allow duplicates in the measure_id column of the conversion factors dataframe. Default is FALSE.
Value
A dataframe containing the original HCES data with additional columns for the conversion factor and weight in kg.