Skip to contents

The Absence Checker runs over a data.frame containing food items with CPC codes, and checks those food items and the nutrients they contain against a list. If a nutrient is showing as present when that food item shouldn't contain that nutrient, the Absence_Check function will sort those values, depending on the user input.

Usage

Absence_Check(
  df,
  assumed_zero_table = Absence_Table,
  assumed_zero_absence_inputs = c("a"),
  method = "check",
  CPC_Code_Column = "CPC_Code",
  comments = TRUE,
  comment_col = "comments",
  Water_check = TRUE,
  water_column = "WATERg",
  CHOAVL_check = TRUE,
  CHOAVL_column = "CHOAVLg",
  CHOAVLDF_check = TRUE,
  CHOAVLDFg_std_column = "CHOAVLDFg_standardised",
  ALC_check = TRUE,
  ALC_column = "ALCg",
  FIBG_check = TRUE,
  FIBG_column = "FIBGg",
  NIA_check = TRUE,
  NIA_column = "NIAmg",
  VITB6_check = TRUE,
  VITB6_column = "VITB6_mg_standardised",
  VITB12_check = TRUE,
  VITB12_column = "VITB12mcg",
  CU_check = TRUE,
  CU_column = "CUmg",
  F22D6N3_check = TRUE,
  F22D6N3_column = "F22D6N3g",
  F20D5N3_check = TRUE,
  F20D5N3_column = "F20D5N3g",
  assumed_zero_water_col = "WATERg",
  assumed_zero_CHOAVL_col = "CHOAVLg",
  assumed_zero_CHOAVLDF_col = "CHOAVLDFg_standardised",
  assumed_zero_ALC_col = "ALCg",
  assumed_zero_FIBG_col = "FIBGg",
  assumed_zero_NIA_col = "NIAmg",
  assumed_zero_VITB6_col = "VITB6_mg_standardised",
  assumed_zero_VITB12_col = "VITB12mg",
  assumed_zero_F22D6N3_col = "F22D6N3g",
  assumed_zero_F20D5N3_col = "F20D5N3g",
  assumed_zero_CU_col = "CUmg",
  assumed_zero_CPC_column = "CPC_Code",
  No_Water_CPC_Codes = c(""),
  No_CHOAVL_CPC_Codes = c(""),
  No_CHOAVLDFg_standardised_CPC_Codes = c(""),
  No_ALC_CPC_Codes = c(""),
  No_FIBG_CPC_Codes = c(""),
  No_NIA_CPC_Codes = c(""),
  No_VITB6_CPC_Codes = c(""),
  No_VITB12_CPC_Codes = c(""),
  No_F22D6N3_CPC_Codes = c(""),
  No_F20D5N3_CPC_Codes = c(""),
  No_CU_CPC_Codes = c("")
)

Arguments

df

Required - The data.frame which contains the food items you are looking to check.

assumed_zero_table

Optional - default: Absence_Table - Choose whether to use the supplied preset table which contains information on which CPC code shouldn't contain certain nutrients.

assumed_zero_absence_inputs

Optional - default: c("a")

  • If using the default assumed_zero_table, this allows you to pick which options for selection you want. Choosing c("a") only applies corrections that are certain, c("a", "b") results in corrections being applied to a broader selection of checks and food groups, with high certainty, but less certain than just using c("a").

method

Required - default: "check" - Either "check", "fill_all", or "fill_blank". If set to "check", the function will print out warnings where it encounters values which should be zero. If set to "fill_all", the function will correct any incorrect values to 0. If set to "fill_blank", the function will correct incorrect values to 0 only if they're missing (e.g. NA or "").

CPC_Code_Column

Required - default: "CPC_Code" - the name of the column in df which contains the CPC codes for the food items.

comments

Required - default: TRUE - Either TRUE or FALSE. Choose whether to record the changes made. It is strongly recommended to leave this as TRUE to maintain records of any changes in the data.

comment_col

Optional - default: "comments" - Required if comments is set to TRUE. The name of the column in df where comments should be stored. If the entry for comment_col is not the name of a column in df, then a new column will be created with the name of the entry.

Water_check

Required - default: TRUE - Either TRUE or FALSE. Decide whether you would like to check the Water values in df.

water_column

Optional - default: "WATERg" - Required if comments is set to TRUE. The name of the column in df which contains water values.

CHOAVL_check

Required - default: TRUE - Either TRUE or FALSE. Decide whether you would like to check the Available Carbohydrate values in df.

CHOAVL_column

Optional - default: "CHOAVLg" - Required if CHOAVL_check is set to TRUE. The name of the column in df which contains Available Carbohydrate values.

CHOAVLDF_check

Required - default: TRUE - Either TRUE or FALSE. Decide whether you would like to check the Available Carbohydrate (calculated by difference) values in df.

CHOAVLDFg_std_column

Optional - default: "CHOAVLDFg_standardised" - Required if CHOAVLDF_check is set to TRUE. The name of the column in df which contains Available Carbohydrate (calculated by difference) values.

ALC_check

Required - default: TRUE - Either TRUE or FALSE. Decide whether you would like to check the Alcohol values in df.

ALC_column

Optional - default: "ALCg" - Required if ALC_check is set to TRUE. The name of the column in df which contains Alcohol values.

FIBG_check

Required - default: TRUE - Either TRUE or FALSE. Decide whether you would like to check the Fibre values in df.

FIBG_column

Optional - default: "FIBGg" - Required if FIBG_check is set to TRUE. The name of the column in df which contains Fibre values.

NIA_check

Required - default: TRUE - Either TRUE or FALSE. Decide whether you would like to check the Niacin values in df.

NIA_column

Optional - default: "NIAmg" - Required if NIA_check is set to TRUE. The name of the column in df which contains Niacin values.

VITB6_check

Required - default: TRUE - Either TRUE or FALSE. Decide whether you would like to check the Vitamin B6 values in df.

VITB6_column

Optional - default: "VITB6_mg_standardised" - Required if VITB6_check is set to TRUE. The name of the column in df which contains Vitamin B6 values.

VITB12_check

Required - default: TRUE - Either TRUE or FALSE. Decide whether you would like to check the Vitamin B12 values in df.

VITB12_column

Optional - default: "VITB12mcg" - Required if VITB12_check is set to TRUE. The name of the column in df which contains Vitamin B12 values.

CU_check

Required - default: TRUE - Either TRUE or FALSE. Decide whether you would like to check the Copper values in df.

CU_column

Optional - default: "CUmg" - Required if CU_check is set to TRUE. The name of the column in df which contains Copper values.

F22D6N3_check

Required - default: TRUE - Either TRUE or FALSE. Decide whether you would like to check the F22D6N3 values in df.

F22D6N3_column

Optional - default: "F22D6N3g" - Required if F22D6N3_check is set to TRUE. The name of the column in df which contains F22D6N3 values.

F20D5N3_check

Required - default: TRUE - Either TRUE or FALSE. Decide whether you would like to check the F20D5N3 values in df.

F20D5N3_column

Optional - default: "F20D5N3g" - Required if F20D5N3_check is set to TRUE. The name of the column in df which contains F20D5N3 values.

assumed_zero_water_col

Optional - default: "WATERg" - The column in the assumed_zero_table that contains the absence status of water for different food groups. If using assumed_zero_table, and if using the default table, there is no need to change this. If using a modified table, please change this to match the column that lists water in that modified table.

assumed_zero_CHOAVL_col

Optional - default: "CHOAVLg" - The column in the assumed_zero_table that contains the absence status of Carbohydrates for different food groups. If using assumed_zero_table, and if using the default table, there is no need to change this. If using a modified table, please change this to match the column that lists Carbohydrates in that modified table.

assumed_zero_CHOAVLDF_col

Optional - default: "CHOAVLDFg_standardised" - The column in the assumed_zero_table that contains the absence status of Carbohydrates calculated by difference for different food groups. If using assumed_zero_table, and if using the default table, there is no need to change this. If using a modified table, please change this to match the column that lists Carbohydrates calculated by difference in that modified table.

assumed_zero_ALC_col

Optional - default: "ALCg" - The column in the assumed_zero_table that contains the absence status of alcohol for different food groups. If using assumed_zero_table, and if using the default table, there is no need to change this. If using a modified table, please change this to match the column that lists Alcohol in that modified table.

assumed_zero_FIBG_col

Optional - default: "FIBGg" - The column in the assumed_zero_table that contains the absence status of Fibre for different food groups. If using assumed_zero_table, and if using the default table, there is no need to change this. If using a modified table, please change this to match the column that lists Fibre in that modified table.

assumed_zero_NIA_col

Optional - default: "NIAmg" - The column in the assumed_zero_table that contains the absence status of Niacin for different food groups. If using assumed_zero_table, and if using the default table, there is no need to change this. If using a modified table, please change this to match the column that lists Niacin in that modified table.

assumed_zero_VITB6_col

Optional - default: "VITB6_mg_standardised" - The column in the assumed_zero_table that contains the absence status of Vitamin B6 for different food groups. If using assumed_zero_table, and if using the default table, there is no need to change this. If using a modified table, please change this to match the column that lists Vitamin B6 in that modified table.

assumed_zero_VITB12_col

Optional - default: "VITB12mg" - The column in the assumed_zero_table that contains the absence status of Vitamin B12 for different food groups. If using assumed_zero_table, and if using the default table, there is no need to change this. If using a modified table, please change this to match the column that lists Vitamin B12 in that modified table.

assumed_zero_F22D6N3_col

Optional - default: "F22D6N3g" - The column in the assumed_zero_table that contains the absence status of F22D6N3 for different food groups. If using assumed_zero_table, and if using the default table, there is no need to change this. If using a modified table, please change this to match the column that lists F22D6N3 in that modified table.

assumed_zero_F20D5N3_col

Optional - default: "F20D5N3g" - The column in the assumed_zero_table that contains the absence status of F20D5N3 for different food groups. If using assumed_zero_table, and if using the default table, there is no need to change this. If using a modified table, please change this to match the column that lists F20D5N3 in that modified table.

assumed_zero_CU_col

Optional - default: "CUmg" - The column in the assumed_zero_table that contains the absence status of Copper for different food groups. If using assumed_zero_table, and if using the default table, there is no need to change this. If using a modified table, please change this to match the column that lists Copper in that modified table.

assumed_zero_CPC_column

Optional - default: "CPC_Code" - The column in the assumed_zero_table that contains the CPC Codes for different food groups. If using assumed_zero_table, and if using the default table, there is no need to change this. If using a modified table, please change this to match the column that lists the CPC Codes in that modified table.

No_Water_CPC_Codes

Optional - default: c("") - Required if not using the assumed_zero_table input, if water_check is TRUE. Please input the CPC codes where you wouldn't expect to find Water.

No_CHOAVL_CPC_Codes

Optional - default: c("") - Required if not using the assumed_zero_table input, if CHOAVL_check is TRUE. Please input the CPC codes where you wouldn't expect to find Carbohydrates.

No_CHOAVLDFg_standardised_CPC_Codes

Optional - default: c("") - Required if not using the assumed_zero_table input, if CHOAVLDF_check is TRUE. Please input the CPC codes where you wouldn't expect to find Carbohydrates calculated by difference.

No_ALC_CPC_Codes

Optional - default: c("") - Required if not using the assumed_zero_table input, if ALC_check is TRUE. Please input the CPC codes where you wouldn't expect to find Alcohol.

No_FIBG_CPC_Codes

Optional - default: c("") - Required if not using the assumed_zero_table input, if FIBG_check is TRUE. Please input the CPC codes where you wouldn't expect to find Fibre.

No_NIA_CPC_Codes

Optional - default: c("") - Required if not using the assumed_zero_table input, if NIA_check is TRUE. Please input the CPC codes where you wouldn't expect to find Niacin.

No_VITB6_CPC_Codes

Optional - default: c("") - Required if not using the assumed_zero_table input, if VITB6_check is TRUE. Please input the CPC codes where you wouldn't expect to find Vitamin B6.

No_VITB12_CPC_Codes

Optional - default: c("") - Required if not using the assumed_zero_table input, if VITB12_check is TRUE. Please input the CPC codes where you wouldn't expect to find Vitamin B12.

No_F22D6N3_CPC_Codes

Optional - default: c("") - Required if not using the assumed_zero_table input, if F22D6N3_check is TRUE. Please input the CPC codes where you wouldn't expect to find F22D6N3.

No_F20D5N3_CPC_Codes

Optional - default: c("") - Required if not using the assumed_zero_table input, if F20D5N3_check is TRUE. Please input the CPC codes where you wouldn't expect to find F20D5N3.

No_CU_CPC_Codes

Optional - default: c("") - Required if not using the assumed_zero_table input, if CU_check is TRUE. Please input the CPC codes where you wouldn't expect to find Copper.

Value

If method = "check", the function will output a list of problematic entries in the data.frame to the console for manual investigation. If method = "fill_all", the output will be a data.frame that mimics the input df, but with nutrient values changed where an error is detected - e.g. if a food item is in a CPC group that shouldn't contain water, and it does, then the water value for that item will be changed to 0. If method = "fill_blank", the output will be a data.frame that mimics the input df, but with nutrient values changed where blank value is detect where we can assume the value to be 0 - e.g. if a food item is in a CPC group that shouldn't contain water, and the water value for that item is NA, or "", then the water value for that item will be changed to 0.