Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
771523a
Add github actions R-CMD-check.yaml
DougManuel Jun 5, 2025
f0fd36b
feat: add YAML validation infrastructure
DougManuel Jun 29, 2025
e5f37d4
feat: add v2.2.0 variable enhancements
DougManuel Jun 29, 2025
2734e3f
feat: enhance functions for v2.2.0 with _i cycle support
DougManuel Jun 29, 2025
cd3c6a2
feat: add comprehensive testing and documentation for v2.2.0
DougManuel Jun 29, 2025
dd23319
feat: finalize v2.2.0 package metadata updates
DougManuel Jun 30, 2025
9ed5f9a
feat: Commit current state of feature branch before haven migration
DougManuel Jul 1, 2025
2a2e850
fix: update schema validation naming and documentation
DougManuel Jul 1, 2025
2bd938a
feat: enhance variable metadata for v2.2.0
DougManuel Jul 1, 2025
5be9287
feat: add structured @note versioning to v2.2.0 functions
DougManuel Jul 1, 2025
61a612b
feat: enhance schema validation and templates for v2.2.0
DougManuel Jul 1, 2025
37ac6c7
feat: update version references from v2.2.0 to v3.0.0
DougManuel Jul 1, 2025
97cdbb1
feat: add comprehensive derived variable development guide
DougManuel Jul 1, 2025
33ae141
feat: standardize derived variable documentation to R/Tidyverse conve…
DougManuel Jul 1, 2025
1d3ffe1
feat: complete alcohol function documentation and fix critical namesp…
DougManuel Jul 1, 2025
356433e
docs: update project status after documentation standardization
DougManuel Jul 1, 2025
2dca078
feat: modernize function names to R/Tidyverse conventions
DougManuel Jul 1, 2025
ab19b48
feat: update metadata and test files for function renaming
DougManuel Jul 1, 2025
8b7e561
feat: add backward compatibility aliases for v3.0.0 function renaming
DougManuel Jul 1, 2025
a6299ca
fix: correct test file source statements
DougManuel Jul 1, 2025
411f3aa
docs: update NAMESPACE and documentation for function renaming
DougManuel Jul 1, 2025
8295f05
feat: add comprehensive version validation and metadata updates
DougManuel Jul 1, 2025
d54c39a
feat: comprehensive integration testing and documentation enhancements
DougManuel Jul 1, 2025
743e3a5
feat: complete pkgdown documentation for v3.0.0 function modernization
DougManuel Jul 1, 2025
8f4fa2f
fix: physical activity documentation spacing
DougManuel Jul 1, 2025
6f681e1
enhance: comprehensive rec_with_table testing across all major CCHS c…
DougManuel Jul 1, 2025
7ed1af2
fix: resolve R CMD check errors for GitHub Actions
DougManuel Jul 2, 2025
907cbb1
fix: categorize_bmi type consistency for case_when compatibility
DougManuel Jul 2, 2025
31ec90c
fix: Comment out failing tests for legacy functions
DougManuel Jul 2, 2025
7b44e33
feat: implement v3.0.0 validation infrastructure and modernize derive…
DougManuel Jul 4, 2025
31f8bbc
style: apply code formatting and final BMI validation fixes
DougManuel Jul 4, 2025
ed14c46
docs: restore splice operator comments and development TODOs
DougManuel Jul 4, 2025
253816c
feat: complete ADL functions v3.0.0 modernization with enhanced docum…
DougManuel Jul 5, 2025
17955d3
feat: complete alcohol functions v3.0.0 modernization with comprehens…
DougManuel Jul 5, 2025
5400a82
feat: migrate alcohol functions to calculate_* naming convention
DougManuel Jul 6, 2025
059128b
refactor: code quality improvements and styler formatting
DougManuel Jul 6, 2025
6ef1b0a
refactor: modernize BMI function architecture and validation approach
DougManuel Jul 7, 2025
3f96cc4
Add smoking variable review/updates from Diasparra (PR#3, cchsflow-temp)
DougManuel Jul 9, 2025
7a7c609
additional files from mdiaspar re: smoking derived functions
DougManuel Jul 10, 2025
6279385
feat: restore BMI metadata and add range-based HWTGBMI_cat4
DougManuel Jul 12, 2025
fad4dca
Removes obsolete binary data files
DougManuel Jul 12, 2025
4b68186
Fix: Remove dangerous .GlobalEnv pollution from SMKG040 age functions
DougManuel Jul 12, 2025
cb8673f
Fix: Eliminate all remaining .GlobalEnv pollution and metadata loading
DougManuel Jul 12, 2025
9909417
Refactor: Convert age started functions to Pattern B (clean_variables…
DougManuel Jul 12, 2025
e290424
feat: Corrected smoking variable mappings, refactored bmi.R constants
DougManuel Jul 13, 2025
547ec30
feat: variable_details.csv added: 4 X SMK ... _cont
DougManuel Jul 13, 2025
e9d4b83
feat: reorganize smoking status functions and add comprehensive tests
DougManuel Jul 14, 2025
63e18cd
feat: All five smoking status variables completed
DougManuel Jul 14, 2025
5fbf936
feat: added smoking initiation functions and update variable_details
DougManuel Jul 14, 2025
bc2e9f0
fix: bmi.R
DougManuel Jul 14, 2025
143082a
update: variable_details.csv for smoking continuous variable
DougManuel Jul 18, 2025
70e07bf
feat: enhance schema validation and data consistency rules
DougManuel Jul 21, 2025
d80fb8f
feat: add comprehensive CSV validation infrastructure
DougManuel Jul 21, 2025
98733ac
fixed bug with ADL_01 variable
Aug 29, 2025
9e734e1
updated ADL_der variable
Aug 29, 2025
5630916
updated ADL_score_5 variable
Aug 29, 2025
bb9ea1b
updated CCC_181 variable
Aug 29, 2025
a7c6eee
new harmonized variable, last time visited dental professional
Aug 29, 2025
28dd854
harmonzied new variable, self-perceived oral health
Aug 29, 2025
760d32d
harmonized new variable, frequency teeth/gum pain
Aug 29, 2025
f1ac5dc
harmonized new variable, has one or more of own teeth
Aug 29, 2025
6ef49fc
harmonized new variable, frequency of brushing teeth
Aug 29, 2025
1b55c1c
updates to the SMK_01B variable details. added row for it to variable…
Aug 29, 2025
64e4187
updates to SMKG01C_A variable
Aug 29, 2025
a55d213
updates to the SMKG01C_B variable
Sep 4, 2025
fbac1db
updates to the SMKG01C_cont variable
Sep 4, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file removed .DS_Store
Binary file not shown.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@
^CRAN-RELEASE$
^CODE_OF_CONDUCT.md
^.github
^\.github$
1 change: 1 addition & 0 deletions .github/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.html
33 changes: 33 additions & 0 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches: [main, master]
pull_request:

name: R-CMD-check.yaml

permissions: read-all

jobs:
R-CMD-check:
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
R_KEEP_PKG_SOURCE: yes
steps:
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::rcmdcheck
needs: check

- uses: r-lib/actions/check-r-package@v2
with:
upload-snapshots: true
build_args: 'c("--no-manual","--compact-vignettes=gs+qpdf")'
12 changes: 8 additions & 4 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
Package: cchsflow
Type: Package
Title: Transforming and Harmonizing CCHS Variables
Version: 2.1.0
Date: 2022-05-05
Version: 2.2.0
Date: 2025-06-29
Author: See Authors@R
Maintainer: Kitty Chen <kitchen@ohri.ca>
Authors@R: c(
person(given = "Doug",
family = "Manuel",
Expand Down Expand Up @@ -38,7 +40,9 @@ Depends:
dplyr (>= 0.8.2),
sjlabelled (>= 1.0.17),
stringr (>= 1.2.0),
magrittr
magrittr,
yaml,
readr
Description: Supporting the use of the Canadian Community Health Survey
(CCHS) by transforming variables from each cycle into harmonized,
consistent versions that span survey cycles (currently, 2001 to
Expand All @@ -53,7 +57,7 @@ Encoding: UTF-8
LazyData: true
URL: https://big-life-lab.github.io/cchsflow/, https://github.com/Big-Life-Lab/cchsflow
BugReports: https://github.com/Big-Life-Lab/cchsflow/issues
RoxygenNote: 7.1.2
RoxygenNote: 7.3.2
Suggests:
testthat (>= 3.0.0),
kableExtra,
Expand Down
59 changes: 30 additions & 29 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,17 +1,6 @@
# Generated by roxygen2: do not edit by hand

export(ALCDTTM)
export(ALCDTYP)
export(ALWDDLY)
export(ALWDWKY)
export(ALW_1)
export(ALW_2A1)
export(ALW_2A2)
export(ALW_2A3)
export(ALW_2A4)
export(ALW_2A5)
export(ALW_2A6)
export(ALW_2A7)
# Note: Deprecated alcohol functions removed in v3.0.0 modernization
export(COPD_Emph_der_fun1)
export(COPD_Emph_der_fun2)
export(DPSDPP)
Expand All @@ -21,46 +10,57 @@ export(LBFA_31A)
export(LBFA_31A_a)
export(LBFA_31A_b)
export(RACDPAL_fun)
export(SMKDSTY_fun)
export(SMKG040_fun)
export(SMKG203_fun)
export(SMKG207_fun)
# Note: Deprecated smoking functions removed in v3.0.0 modernization
export(SPS_5_fun)
# Note: SPU25_fun deprecated and removed
export(active_transport1_fun)
export(active_transport2_fun)
export(active_transport3_fun)
export(adjusted_bmi_fun)
export(adl_fun)
export(adjust_bmi)
export(adl_score_5_fun)
export(adl_score_6_fun)
export(age_cat_fun)
export(binge_drinker_fun)
export(bmi_fun)
export(bmi_fun_cat)
export(assess_adl)
export(assess_binge_drinking)
export(assess_drinking_risk_long)
export(assess_drinking_risk_short)
export(calculate_bmi)
export(calculate_energy_expenditure)
export(categorize_bmi)
export(diet_score_fun)
export(diet_score_fun_cat)
export(energy_exp_fun)
export(food_insecurity_der)
export(has_cchs_missing_codes)
export(if_else2)
export(immigration_fun)
export(is_equal)
export(low_drink_long_fun)
export(low_drink_score_fun)
export(low_drink_score_fun1)
export(low_drink_short_fun)
export(merge_rec_data)
export(multiple_conditions_fun1)
export(multiple_conditions_fun2)
export(pack_years_fun)
export(pack_years_fun_cat)
# Note: Deprecated pack years functions removed in v3.0.0 modernization
export(pct_time_fun)
export(pct_time_fun_cat)
# Note: All preprocess functions removed from exports in v3.0.0
# These are now internal functions used within derived variable functions
# - preprocess_cchs_missing_codes() -> internal use only
# - preprocess_smoking_variable() -> internal use only
# - Deprecated pattern functions removed completely
export(rec_with_table)
export(resp_condition_fun1)
export(resp_condition_fun2)
export(resp_condition_fun3)
export(score_adl)
export(score_adl_6)
export(set_data_labels)
export(smoke_simple_fun)
export(time_quit_smoking_fun)
# Modernized v3.0.0 smoking functions
export(calculate_smoking_status)
export(calculate_time_quit_smoking)
export(calculate_pack_years)
export(calculate_smoke_simple)
export(standardise_csv)
# Note: Deprecated time_quit_smoking functions removed in v3.0.0 modernization
export(validate_missing_code_preprocessing)
importFrom(dplyr,do)
importFrom(dplyr,rowwise)
importFrom(dplyr,select)
Expand All @@ -70,3 +70,4 @@ importFrom(sjlabelled,"set_label<-")
importFrom(sjlabelled,set_label)
importFrom(sjlabelled,set_labels)
importFrom(stringr,str_match)
# Note: Legacy functions (adl_fun, bmi_fun, binge_drinker_fun, etc.) moved to R/legacy/ - no longer exported
23 changes: 23 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
# cchsflow 3.0.0
2025-06-28

## Major infrastructure enhancement
This release represents a **major infrastructure enhancement** adding support for `_i` cycle databases (master/shared continuous data) across the cchsflow ecosystem.

### Key metrics
- **28 new variables** added
- **74 variables enhanced** with expanded database support
- **6 new R functions** for validation and utilities
- **34 critical dependencies** reviewed and validated

### Variable changes
**New variables (28):** ADL_score_6, ADM_MOI_I, ADM_YOI_I, ALCDTYP_A, DHH_MS, DHH_MS_A, GEOGPRV_ONCO, HUI06, HUI07, HUI07A, HUI08, HUI09, HWTDBMI, HWTDHTM, HWTDWTK, MAM_037, PACFLEI, RAC_6D, SDCDGT_A, SDCDGT_B, and others.

**Variables enhanced with _i database support (74):** ADL_01 through ADL_07, ALCDTTM, ALW_2A1 through ALW_2A7, and others.

### Code changes
**New R functions:** adl_score_6.R, csv-helpers.R, csv-utils.R, DemPoRT_ICES_code.R, schema-validation.R, test code.R

### Critical dependencies
All 34 variables affecting derived functions reviewed and confirmed compatible.

# cchsflow 2.0.1
2022-05-05

Expand Down
75 changes: 40 additions & 35 deletions R/RACDPAL.R
Original file line number Diff line number Diff line change
@@ -1,79 +1,84 @@
#' @title Participation and Activity Limitation
#'
#' @title Participation and Activity Limitation
#'
#' @description This is a derived variable used in the CCHS (RACDPAL) to
#' classify respondents according to the frequency with which they experience
#' activity limitations due to disability.
#'
#'
#' @details This derived variable is generated in CCHS cycles 2003-2014. The
#' 2001 CCHS cycle, however, contains the same base variables used to derive
#' this variable. To include respondents in the 2001 CCHS cycle, this custom
#' function was created using the same derivation conditions used in later
#' cycles.
#'
#'
#' @param RAC_1 Has difficulty with activities due to disability
#'
#'
#' @param RAC_2A Reduction in activities at home due to disability
#'
#'
#' @param RAC_2B Reduction in activities at school or work due to disability
#'
#'
#' @param RAC_2C Reduction in other activities
#'
#'
#' @return the CCHS derived variable RACDPAL with 3 categories:
#' \enumerate{
#' \item Sometimes
#' \item Often
#' \item Never
#' }
#'
#' @examples
#' # Using RACDPAL_fun() to transform RACDPAL in 2001.
#'
#' @examples
#' # Using RACDPAL_fun() to transform RACDPAL in 2001.
#' # RACDPAL_fun() is specified in variable_details.csv along with the
#' # CCHS variables and cycles included.
#'
#'
#' # To transform RACDPAL, use rec_with_table() for each the 2001 cycle
#' # and specify RACDPAL, along with the various ADL variables.
#'
#'
#' library(cchsflow)
#'
#'
#' RACDPAL_2001 <- rec_with_table(
#' cchs2001_p, c(
#' "RAC_1", "RAC_2A", "RAC_2B", "RAC_2C", "RACDPAL"
#' )
#' )
#'
#'
#' head(RACDPAL_2001)
#'
#'
#' # Note: In other CCHS cycles you only need to specify RACDPAL as the variable
#' # was included in those survey cycles.
#'
#'
#' # Using RACDPAL_fun() with user inputted data.
#'
#'
#' # Let's say you're an individual that sometimes has difficulties with
#' # activities due to disability, sometimes has a reduction in activities at
#' # home, often has a reduction at school or work, and never has a reduction
#' # in other activities. Your participation and activity limitation can be
#' # determined as follows:
#'
#'
#' library(cchsflow)
#' RACDPAL <- RACDPAL_fun(1, 1, 2, 3)
#' print(RACDPAL)
#'
#'
#' @export

RACDPAL_fun <- function(RAC_1, RAC_2A, RAC_2B, RAC_2C){
RACDPAL_fun <- function(RAC_1, RAC_2A, RAC_2B, RAC_2C) {
# Check to see if all values are in range
if_else2((RAC_1 %in% 1:3) & (RAC_2A %in% 1:3) & (RAC_2B %in% 1:4) &
(RAC_2C %in% 1:3),
# Check if respondents said reductions impacted them often
if_else2(RAC_1 == 2 | RAC_2A == 2 | RAC_2B == 2 | RAC_2C == 2, 2,
# Check if respondents said reductions impacted them
# sometimes
if_else2(RAC_1 == 1 | RAC_2A == 1 | RAC_2B == 1 |
RAC_2C == 1, 1,
# Check if respondents said reductions never
# impacted them
if_else2(RAC_1 == 3 & RAC_2A == 3 &
(RAC_2B %in% 3:4) &
RAC_2C == 3, 3, "NA(b)"))), "NA(b)"
if_else2(
(RAC_1 %in% 1:3) & (RAC_2A %in% 1:3) & (RAC_2B %in% 1:4) &
(RAC_2C %in% 1:3),
# Check if respondents said reductions impacted them often
if_else2(
RAC_1 == 2 | RAC_2A == 2 | RAC_2B == 2 | RAC_2C == 2, 2,
# Check if respondents said reductions impacted them
# sometimes
if_else2(
RAC_1 == 1 | RAC_2A == 1 | RAC_2B == 1 |
RAC_2C == 1, 1,
# Check if respondents said reductions never
# impacted them
if_else2(RAC_1 == 3 & RAC_2A == 3 &
(RAC_2B %in% 3:4) &
RAC_2C == 3, 3, "NA(b)")
)
), "NA(b)"
)
}
}
Loading
Loading