Skip to contents

Computes the Global Dietary Recommendation (GDR) score from cleaned dietary recall data. Uses either the package FCT database (online CSV) or a user-supplied mapping.

Usage

compute_gdr(
  recall_data,
  id_col,
  food_item_col,
  use_fct_db = FALSE,
  gdr_map_data = NULL,
  gdr_map_food = NULL,
  gdr_map_col = NULL
)

Arguments

recall_data

A data frame containing at least the ID column and the food item column.

id_col

Character. Name of the identifier column in recall_data (e.g., "survey_id").

food_item_col

Character. Column in recall_data containing food item names.

use_fct_db

Logical, default = FALSE. If TRUE, uses the package's online FCT database (gdr_category column).

gdr_map_data

Optional. A user-provided mapping data frame with food items and GDR categories. Required if use_fct_db = FALSE.

gdr_map_food

Character. Column name in gdr_map_data that matches food items.

gdr_map_col

Character. Column name in gdr_map_data containing the GDR category.

Value

A tibble with:

  • The ID column (as provided in id_col)

  • One-hot encoded GDR group indicators

  • gdrplus = sum of positive GDR categories

  • gdrminus = sum of negative GDR categories

  • gdr_score = net score (gdrplus - gdrminus + 9)

Details

  • Valid GDR+ categories: Whole Grains, Legumes, Nuts And Seeds, Vitamin A-Rich Orange Vegetables, Roots And Tubers, Dark Green Leafy Vegetables, Other Vegetables, Vitamin A-Rich Fruits, Citrus Fruits, Other Fruits.

  • Valid GDR– categories: Sodas/Sugar-Sweetened Beverages, Baked/Grain-Based Sweets, Other Sweets, Processed Meat, Unprocessed Red Meat, Deep-Fried Foods, Fast Food And Instant Noodles, Packaged Ultra-Processed Salty Snacks.

  • Processed Meat is scored as 2 if consumed.

  • Warns if unmapped items are found in recall_data and ignored in subsequent computation.

  • Errors if invalid GDR categories are found in mapping.

Examples

if (FALSE) { # \dontrun{
# Using online FCT DB
result <- compute_gdr(
  recall_data   = dietrecall_example$food_details,
  id_col        = "survey_id",
  food_item_col = "desc_of_food",
  use_fct_db    = TRUE
)

# Using custom mapping
gdr_map <- data.frame(
  item = c("Ugali", "Cola"),
  category = c("Whole Grains", "Sodas/Sugar-Sweetened Beverages")
)

result <- compute_gdr(
  recall_data   = dietrecall_example$food_details,
  id_col        = "survey_id",
  food_item_col = "desc_of_food",
  use_fct_db    = FALSE,
  gdr_map_data  = gdr_map,
  gdr_map_food  = "item",
  gdr_map_col   = "category"
)
} # }