Problem
inst/extdata/variable_details.csv on v3 (d98e9d6) references smoking derivation functions that do not exist in the package, so rec_with_table() fails (or silently skips) when harmonizing through the worksheet path:
Error in get(custom_function_name) : object 'calculate_SMKG040' not found
Worksheet recEnd |
Actual function in R/smoke-start.R |
Func::calculate_SMKG040 |
calculate_SMKG040_cont() |
Func::calculate_SMKG203_continuous |
calculate_SMKG203_cont() |
Func::calculate_SMKG203_from_combined |
calculate_SMKG203_cont() |
Func::calculate_SMKG207_continuous |
calculate_SMKG207_cont() |
Func::calculate_SMKG207_from_combined |
calculate_SMKG207_cont() |
The DerivedVar:: feeder lists in the same rows also no longer match the function signatures:
| Variable (block) |
Worksheet feeders |
Function signature expects |
SMKG040_cont (PUMF 2001–2003, 2005–2014) |
[SMKG203_pre2005, SMKG207_pre2005] / [SMKG203_2005plus, SMKG207_2005plus] (categorical) |
calculate_SMKG040_cont(SMKG203_cont, SMKG207_cont) (continuous midpoints) |
SMKG203_cont (PUMF 2015+) |
[SMK_005, SMKG040] (grouped category) |
calculate_SMKG203_cont(SMK_005, SMKG040_cont) |
SMKG207_cont (PUMF 2015+) |
[SMK_005, SMK_030, SMKG040] — three feeders |
calculate_SMKG207_cont(SMK_030, SMKG040_cont) — two parameters (third feeder lands in output_format) |
SMKG207_cont / SMK_207 (Master 2015+) |
[SMK_005, SMK_030, SMK_040] — three feeders |
same two-parameter signature |
Impact
SMKG040_cont cannot be derived for PUMF 2001–2014 or Master 2001–2014, which breaks the age_start_smoking chain through rec_with_table().
SMKG203_cont / SMKG207_cont (2015+) and SMK_040 / SMK_203 / SMK_207 (Master 2015+) hit the same phantom-name failure.
The test suite passes because it calls the calculate_*() functions directly with vectors; Func:: resolution from the worksheet is only exercised by an actual rec_with_table() run.
Proposed fix (validated locally)
Exact cell replacements in variable_details.csv:
Func::calculate_SMKG040 → Func::calculate_SMKG040_cont
Func::calculate_SMKG203_continuous and Func::calculate_SMKG203_from_combined → Func::calculate_SMKG203_cont
Func::calculate_SMKG207_continuous and Func::calculate_SMKG207_from_combined → Func::calculate_SMKG207_cont
DerivedVar::[SMKG203_pre2005, SMKG207_pre2005] and DerivedVar::[SMKG203_2005plus, SMKG207_2005plus] → DerivedVar::[SMKG203_cont, SMKG207_cont]
DerivedVar::[SMK_005, SMKG040] → DerivedVar::[SMK_005, SMKG040_cont]
DerivedVar::[SMK_005, SMK_030, SMKG040] → DerivedVar::[SMK_030, SMKG040_cont]
DerivedVar::[SMK_005, SMK_030, SMK_040] → DerivedVar::[SMK_030, SMK_040]
This matches the era design documented in calculate_SMKG040_cont() (2001–2014: combine 203/207 midpoints into 040; 2015+: derive 203/207 from directly-recoded SMKG040_cont via the SMK_005/SMK_030 gates). The packaged .rda worksheets would need rebuilding from the CSVs afterward. We have these fixes applied locally and are validating them against the CSHM (cshgm-dev) harmonization pipeline; happy to open a PR.
Context
Found while integrating cchsflow v3 into the CSHM pipeline, which passes the v3 CSV worksheets explicitly to rec_with_table().
Problem
inst/extdata/variable_details.csvonv3(d98e9d6) references smoking derivation functions that do not exist in the package, sorec_with_table()fails (or silently skips) when harmonizing through the worksheet path:recEndR/smoke-start.RFunc::calculate_SMKG040calculate_SMKG040_cont()Func::calculate_SMKG203_continuouscalculate_SMKG203_cont()Func::calculate_SMKG203_from_combinedcalculate_SMKG203_cont()Func::calculate_SMKG207_continuouscalculate_SMKG207_cont()Func::calculate_SMKG207_from_combinedcalculate_SMKG207_cont()The
DerivedVar::feeder lists in the same rows also no longer match the function signatures:SMKG040_cont(PUMF 2001–2003, 2005–2014)[SMKG203_pre2005, SMKG207_pre2005]/[SMKG203_2005plus, SMKG207_2005plus](categorical)calculate_SMKG040_cont(SMKG203_cont, SMKG207_cont)(continuous midpoints)SMKG203_cont(PUMF 2015+)[SMK_005, SMKG040](grouped category)calculate_SMKG203_cont(SMK_005, SMKG040_cont)SMKG207_cont(PUMF 2015+)[SMK_005, SMK_030, SMKG040]— three feederscalculate_SMKG207_cont(SMK_030, SMKG040_cont)— two parameters (third feeder lands inoutput_format)SMKG207_cont/SMK_207(Master 2015+)[SMK_005, SMK_030, SMK_040]— three feedersImpact
SMKG040_contcannot be derived for PUMF 2001–2014 or Master 2001–2014, which breaks theage_start_smokingchain throughrec_with_table().SMKG203_cont/SMKG207_cont(2015+) andSMK_040/SMK_203/SMK_207(Master 2015+) hit the same phantom-name failure.The test suite passes because it calls the
calculate_*()functions directly with vectors;Func::resolution from the worksheet is only exercised by an actualrec_with_table()run.Proposed fix (validated locally)
Exact cell replacements in
variable_details.csv:Func::calculate_SMKG040→Func::calculate_SMKG040_contFunc::calculate_SMKG203_continuousandFunc::calculate_SMKG203_from_combined→Func::calculate_SMKG203_contFunc::calculate_SMKG207_continuousandFunc::calculate_SMKG207_from_combined→Func::calculate_SMKG207_contDerivedVar::[SMKG203_pre2005, SMKG207_pre2005]andDerivedVar::[SMKG203_2005plus, SMKG207_2005plus]→DerivedVar::[SMKG203_cont, SMKG207_cont]DerivedVar::[SMK_005, SMKG040]→DerivedVar::[SMK_005, SMKG040_cont]DerivedVar::[SMK_005, SMK_030, SMKG040]→DerivedVar::[SMK_030, SMKG040_cont]DerivedVar::[SMK_005, SMK_030, SMK_040]→DerivedVar::[SMK_030, SMK_040]This matches the era design documented in
calculate_SMKG040_cont()(2001–2014: combine 203/207 midpoints into 040; 2015+: derive 203/207 from directly-recodedSMKG040_contvia theSMK_005/SMK_030gates). The packaged.rdaworksheets would need rebuilding from the CSVs afterward. We have these fixes applied locally and are validating them against the CSHM (cshgm-dev) harmonization pipeline; happy to open a PR.Context
Found while integrating cchsflow v3 into the CSHM pipeline, which passes the v3 CSV worksheets explicitly to
rec_with_table().