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. Choosingc("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 usingc("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 indf
which contains the CPC codes for the food items.- comments
Required - default:
TRUE
- EitherTRUE
orFALSE
. Choose whether to record the changes made. It is strongly recommended to leave this asTRUE
to maintain records of any changes in the data.- comment_col
Optional - default:
"comments"
- Required ifcomments
is set toTRUE
. The name of the column indf
where comments should be stored. If the entry forcomment_col
is not the name of a column indf
, then a new column will be created with the name of the entry.- Water_check
Required - default:
TRUE
- EitherTRUE
orFALSE
. Decide whether you would like to check the Water values indf
.- water_column
Optional - default:
"WATERg"
- Required ifcomments
is set toTRUE
. The name of the column indf
which contains water values.- CHOAVL_check
Required - default:
TRUE
- EitherTRUE
orFALSE
. Decide whether you would like to check the Available Carbohydrate values indf
.- CHOAVL_column
Optional - default:
"CHOAVLg"
- Required ifCHOAVL_check
is set toTRUE
. The name of the column indf
which contains Available Carbohydrate values.- CHOAVLDF_check
Required - default:
TRUE
- EitherTRUE
orFALSE
. Decide whether you would like to check the Available Carbohydrate (calculated by difference) values indf
.- CHOAVLDFg_std_column
Optional - default:
"CHOAVLDFg_standardised"
- Required ifCHOAVLDF_check
is set toTRUE
. The name of the column indf
which contains Available Carbohydrate (calculated by difference) values.- ALC_check
Required - default:
TRUE
- EitherTRUE
orFALSE
. Decide whether you would like to check the Alcohol values indf
.- ALC_column
Optional - default:
"ALCg"
- Required ifALC_check
is set toTRUE
. The name of the column indf
which contains Alcohol values.- FIBG_check
Required - default:
TRUE
- EitherTRUE
orFALSE
. Decide whether you would like to check the Fibre values indf
.- FIBG_column
Optional - default:
"FIBGg"
- Required ifFIBG_check
is set toTRUE
. The name of the column indf
which contains Fibre values.- NIA_check
Required - default:
TRUE
- EitherTRUE
orFALSE
. Decide whether you would like to check the Niacin values indf
.- NIA_column
Optional - default:
"NIAmg"
- Required ifNIA_check
is set toTRUE
. The name of the column indf
which contains Niacin values.- VITB6_check
Required - default:
TRUE
- EitherTRUE
orFALSE
. Decide whether you would like to check the Vitamin B6 values indf
.- VITB6_column
Optional - default:
"VITB6_mg_standardised"
- Required ifVITB6_check
is set toTRUE
. The name of the column indf
which contains Vitamin B6 values.- VITB12_check
Required - default:
TRUE
- EitherTRUE
orFALSE
. Decide whether you would like to check the Vitamin B12 values indf
.- VITB12_column
Optional - default:
"VITB12mcg"
- Required ifVITB12_check
is set toTRUE
. The name of the column indf
which contains Vitamin B12 values.- CU_check
Required - default:
TRUE
- EitherTRUE
orFALSE
. Decide whether you would like to check the Copper values indf
.- CU_column
Optional - default:
"CUmg"
- Required ifCU_check
is set toTRUE
. The name of the column indf
which contains Copper values.- F22D6N3_check
Required - default:
TRUE
- EitherTRUE
orFALSE
. Decide whether you would like to check the F22D6N3 values indf
.- F22D6N3_column
Optional - default:
"F22D6N3g"
- Required ifF22D6N3_check
is set toTRUE
. The name of the column indf
which contains F22D6N3 values.- F20D5N3_check
Required - default:
TRUE
- EitherTRUE
orFALSE
. Decide whether you would like to check the F20D5N3 values indf
.- F20D5N3_column
Optional - default:
"F20D5N3g"
- Required ifF20D5N3_check
is set toTRUE
. The name of the column indf
which contains F20D5N3 values.- assumed_zero_water_col
Optional - default:
"WATERg"
- The column in theassumed_zero_table
that contains the absence status of water for different food groups. If usingassumed_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 theassumed_zero_table
that contains the absence status of Carbohydrates for different food groups. If usingassumed_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 theassumed_zero_table
that contains the absence status of Carbohydrates calculated by difference for different food groups. If usingassumed_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 theassumed_zero_table
that contains the absence status of alcohol for different food groups. If usingassumed_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 theassumed_zero_table
that contains the absence status of Fibre for different food groups. If usingassumed_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 theassumed_zero_table
that contains the absence status of Niacin for different food groups. If usingassumed_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 theassumed_zero_table
that contains the absence status of Vitamin B6 for different food groups. If usingassumed_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 theassumed_zero_table
that contains the absence status of Vitamin B12 for different food groups. If usingassumed_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 theassumed_zero_table
that contains the absence status of F22D6N3 for different food groups. If usingassumed_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 theassumed_zero_table
that contains the absence status of F20D5N3 for different food groups. If usingassumed_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 theassumed_zero_table
that contains the absence status of Copper for different food groups. If usingassumed_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 theassumed_zero_table
that contains the CPC Codes for different food groups. If usingassumed_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 theassumed_zero_table
input, ifwater_check
isTRUE
. Please input the CPC codes where you wouldn't expect to find Water.- No_CHOAVL_CPC_Codes
Optional - default:
c("")
- Required if not using theassumed_zero_table
input, ifCHOAVL_check
isTRUE
. 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 theassumed_zero_table
input, ifCHOAVLDF_check
isTRUE
. 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 theassumed_zero_table
input, ifALC_check
isTRUE
. Please input the CPC codes where you wouldn't expect to find Alcohol.- No_FIBG_CPC_Codes
Optional - default:
c("")
- Required if not using theassumed_zero_table
input, ifFIBG_check
isTRUE
. Please input the CPC codes where you wouldn't expect to find Fibre.- No_NIA_CPC_Codes
Optional - default:
c("")
- Required if not using theassumed_zero_table
input, ifNIA_check
isTRUE
. Please input the CPC codes where you wouldn't expect to find Niacin.- No_VITB6_CPC_Codes
Optional - default:
c("")
- Required if not using theassumed_zero_table
input, ifVITB6_check
isTRUE
. 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 theassumed_zero_table
input, ifVITB12_check
isTRUE
. 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 theassumed_zero_table
input, ifF22D6N3_check
isTRUE
. Please input the CPC codes where you wouldn't expect to find F22D6N3.- No_F20D5N3_CPC_Codes
Optional - default:
c("")
- Required if not using theassumed_zero_table
input, ifF20D5N3_check
isTRUE
. Please input the CPC codes where you wouldn't expect to find F20D5N3.- No_CU_CPC_Codes
Optional - default:
c("")
- Required if not using theassumed_zero_table
input, ifCU_check
isTRUE
. 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.