This function creates a derived diet variable (diet_score) based on consumption of fruit, salad, potatoes, carrots, other vegetables and juice. 2 baseline points plus summation of total points for diet attributes. Negative overall scores are recoded to 0, resulting in a range from 0 to 10.

• 1 point per daily fruit and vegetable consumption, excluding fruit juice (maximum 8 points).

• -2 points for high potato intake (>=7 (males), >=5 (females) times/week)

• -2 points for no carrot intake

• -2 points per daily frequency of fruit juice consumption greater than once/day (maximum -10 points)

diet_score_fun(FVCDFRU, FVCDSAL, FVCDPOT, FVCDCAR, FVCDVEG, FVCDJUI, DHH_SEX)

## Arguments

FVCDFRU daily consumption of fruit daily consumption of green salad daily consumption of potatoes daily consumption of carrots daily consumption of other vegetables daily consumption of fruit juice sex; 1 = male, 2 = female

## Details

While diet score can be calculated for all survey respondents, in the 2005 CCHS survey cycle, fruit and vegetable consumption was an optional section in which certain provinces had opted in to be asked to respondents. In this survey cycle, fruit and vegetable consumption was asked to respondents in British Columbia, Ontario, Alberta, and Prince Edward Island. As such, diet score has a large number of missing respondents for this cycle.

## Examples

# Using the diet_score_fun function to create the derived diet variable
# across CCHS cycles.
# diet_score_fun() is specified in the variable_details.csv.

# To create a harmonized diet_score variable across CCHS cycles, use
# rec_with_table() for each CCHS cycle and specify diet_score_fun and the
# required base variables.
# Using merge_rec_data(), you can combine diet_score across cycles.

library(cchsflow)

diet_score2009_2010 <- rec_with_table(
cchs2009_2010_p, c(
"FVCDFRU", "FVCDSAL", "FVCDPOT", "FVCDCAR", "FVCDVEG", "FVCDJUI",
"DHH_SEX", "diet_score"
)
)
#> No variable_details detected.
#> Using the passed data variable name as database_name
#> NOTE for FVCDCAR: 2015 onward changed question to look at all orange-coloured vegetables
#> NOTE for FVCDCAR: Don't know (999.7) and refusal (999.8) not included in 2001, 2015-2016, 2017-2018 CCHS
#> NOTE for FVCDFRU: Don't know (999.7) and refusal (999.8) not included in 2001 CCHS
#> NOTE for FVCDJUI: Don't know (999.7) and refusal (999.8) not included in 2001 CCHS
#> NOTE for FVCDPOT: Don't know (999.7) and refusal (999.8) not included in 2001 CCHS
#> NOTE for FVCDSAL: 2015 onwards changed question to look at dark green vegetables
#> NOTE for FVCDSAL: Don't know (999.7) and refusal (999.8) not included in 2001, 2015-2016, 2017-2018 CCHS
#> NOTE for FVCDVEG: Don't know (999.7) and refusal (999.8) not included in 2001 CCHS

#>   DHH_SEX FVCDCAR FVCDFRU FVCDJUI FVCDPOT FVCDSAL FVCDVEG diet_score
#> 1       2     0.1     4.0     4.0     0.1     0.3       4        4.0
#> 2       2     0.1     1.0     0.1     0.1     0.4       2        5.6
#> 3       2     0.1     0.1     1.0     0.0     0.3       1        3.5
#> 4       1      NA      NA      NA      NA      NA      NA         NA
#> 5       1     0.4     0.6     1.0     0.4     0.1       6        9.5
#> 6       2     0.3     1.0     0.0     0.3     0.3       1        4.9

diet_score2011_2012 <- rec_with_table(
cchs2011_2012_p,c(
"FVCDFRU", "FVCDSAL", "FVCDPOT", "FVCDCAR", "FVCDVEG", "FVCDJUI",
"DHH_SEX", "diet_score"
)
)
#> No variable_details detected.
#> Using the passed data variable name as database_name
#> NOTE for FVCDCAR: 2015 onward changed question to look at all orange-coloured vegetables
#> NOTE for FVCDCAR: Don't know (999.7) and refusal (999.8) not included in 2001, 2015-2016, 2017-2018 CCHS
#> NOTE for FVCDFRU: Don't know (999.7) and refusal (999.8) not included in 2001 CCHS
#> NOTE for FVCDJUI: Don't know (999.7) and refusal (999.8) not included in 2001 CCHS
#> NOTE for FVCDPOT: Don't know (999.7) and refusal (999.8) not included in 2001 CCHS
#> NOTE for FVCDSAL: 2015 onwards changed question to look at dark green vegetables
#> NOTE for FVCDSAL: Don't know (999.7) and refusal (999.8) not included in 2001, 2015-2016, 2017-2018 CCHS
#> NOTE for FVCDVEG: Don't know (999.7) and refusal (999.8) not included in 2001 CCHS

tail(diet_score2011_2012)
#>     DHH_SEX FVCDCAR FVCDFRU FVCDJUI FVCDPOT FVCDSAL FVCDVEG diet_score
#> 195       1     0.1     1.0     0.1     0.1     1.0     1.0        5.2
#> 196       1     0.0     0.4     0.7     0.3     0.0     0.4        1.1
#> 197       1     0.1     0.1     1.0     0.6     0.3     0.7        3.8
#> 198       2     0.1     1.0     0.3     0.1     0.4     0.4        4.0
#> 199       1     1.0     1.0     0.1     1.0     0.3     1.0        4.3
#> 200       2     0.3     2.0     0.0     0.6     0.4     4.0        9.3

combined_diet_score <- suppressWarnings(merge_rec_data(diet_score2009_2010,
diet_score2011_2012))

#>   DHH_SEX FVCDCAR FVCDFRU FVCDJUI FVCDPOT FVCDSAL FVCDVEG diet_score
#> 1       2     0.1     4.0     4.0     0.1     0.3       4        4.0
#> 2       2     0.1     1.0     0.1     0.1     0.4       2        5.6
#> 3       2     0.1     0.1     1.0     0.0     0.3       1        3.5
#> 4       1      NA      NA      NA      NA      NA      NA         NA
#> 5       1     0.4     0.6     1.0     0.4     0.1       6        9.5
#> 6       2     0.3     1.0     0.0     0.3     0.3       1        4.9
tail(combined_diet_score)
#>     DHH_SEX FVCDCAR FVCDFRU FVCDJUI FVCDPOT FVCDSAL FVCDVEG diet_score
#> 395       1     0.1     1.0     0.1     0.1     1.0     1.0        5.2
#> 396       1     0.0     0.4     0.7     0.3     0.0     0.4        1.1
#> 397       1     0.1     0.1     1.0     0.6     0.3     0.7        3.8
#> 398       2     0.1     1.0     0.3     0.1     0.4     0.4        4.0
#> 399       1     1.0     1.0     0.1     1.0     0.3     1.0        4.3
#> 400       2     0.3     2.0     0.0     0.6     0.4     4.0        9.3