Skip to contents

This function calculates the daily fruit and vegetable consumption in a year for respondents in the Canadian Health Measures Survey (CHMS) cycles 3-6. It takes eleven parameters, each representing the number of times per year a specific fruit or vegetable item was consumed. The function then sums up the consumption frequencies of all these items and divides the total by 365 to obtain the average daily consumption of fruits and vegetables in a year.

Usage

find_totalFV_cycles3to6(
  WSDD34Y,
  WSDD35Y,
  GFVD17AY,
  GFVD17BY,
  GFVD17CY,
  GFVD17DY,
  GFVD18Y,
  GFVD19Y,
  GFVD20Y,
  GFVD22Y,
  GFVD23Y
)

Arguments

WSDD34Y

numeric A numeric vector representing the number of times per year orange or grapefruit juice was consumed.

WSDD35Y

numeric A numeric vector representing the number of times per year other fruit juices were consumed.

GFVD17AY

numeric A numeric vector representing the number of times per year citrus fruits were consumed.

GFVD17BY

numeric A numeric vector representing the number of times per year strawberries were consumed (in summer).

GFVD17CY

numeric A numeric vector representing the number of times per year strawberries were consumed (outside summer).

GFVD17DY

numeric A numeric vector representing the number of times per year other fruits were consumed.

GFVD18Y

numeric A numeric vector representing the number of times per year tomato or tomato sauce was consumed.

GFVD19Y

numeric A numeric vector representing the number of times per year lettuce or green leafy salad was consumed.

GFVD20Y

numeric A numeric vector representing the number of times per year spinach, mustard greens, and cabbage were consumed.

GFVD22Y

numeric A numeric vector representing the number of times per year potatoes were consumed.

GFVD23Y

numeric A numeric vector representing the number of times per year other vegetables were consumed.

Value

numeric The average times per day fruits and vegetables were consumed in a year. If inputs are invalid or out of bounds, the function returns a tagged NA.

Details

The function calculates the total consumption of fruits and vegetables in a year by summing up the consumption frequencies of all the input items. It then divides the total by 365 to obtain the average daily consumption of fruits and vegetables in a year.

     **Missing Data Codes:**
     - For all input variables:
       - `9996`: Valid skip. Handled as `haven::tagged_na("a")`.
       - `9997-9999`: Don't know, refusal, or not stated. Handled as `haven::tagged_na("b")`.

See also

find_totalFV_cycles1and2() for cycles 1-2 fruit and vegetable consumption, determine_gooddiet() for overall diet quality

Examples

# Scalar usage: Single respondent
# Example: Calculate average daily fruit and vegetable consumption for a cycle 3-6 respondent
find_totalFV_cycles3to6(
  WSDD34Y = 50, WSDD35Y = 100, GFVD17AY = 150, GFVD17BY = 80, GFVD17CY = 40,
  GFVD17DY = 200, GFVD18Y = 100, GFVD19Y = 80, GFVD20Y = 60, GFVD22Y = 120, GFVD23Y = 90
)
#> [1] 2.931507
# Output: 2.931507

# Example: Respondent has non-response values for all inputs.
result <- find_totalFV_cycles3to6(
  WSDD34Y = 9998, WSDD35Y = 9998, GFVD17AY = 9998, GFVD17BY = 9998, GFVD17CY = 9998,
  GFVD17DY = 9998, GFVD18Y = 9998, GFVD19Y = 9998, GFVD20Y = 9998, GFVD22Y = 9998, GFVD23Y = 9998
)
result # Shows: NA
#> [1] NA
haven::is_tagged_na(result, "b") # Shows: TRUE (confirms it's tagged NA(b))
#> [1] TRUE
format(result, tag = TRUE) # Shows: "NA(b)" (displays the tag)
#> [1] "NA"

# Multiple respondents
find_totalFV_cycles3to6(
  WSDD34Y = c(50, 60), WSDD35Y = c(100, 110), GFVD17AY = c(150, 160), GFVD17BY = c(80, 90),
  GFVD17CY = c(40, 50), GFVD17DY = c(200, 210), GFVD18Y = c(100, 110), GFVD19Y = c(80, 90),
  GFVD20Y = c(60, 70), GFVD22Y = c(120, 130), GFVD23Y = c(90, 100)
)
#> [1] 2.931507 3.232877
# Returns: c(2.931507, 3.232877)