Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
95628c4
packyears bug fix
StaceyFisher Apr 1, 2025
309db6d
Added test for "former daily current occasional smoker" for pack years
yulric Apr 19, 2025
0d70d01
Fix logo font rendering issues and regenerate favicons
DougManuel Jun 4, 2025
2d38302
Merge pull request #136 from Big-Life-Lab/pkgdown-fix
DougManuel Jun 4, 2025
9e27eea
revert to updated logo
DougManuel Jun 4, 2025
13eb0b5
update logo -- again
DougManuel Jun 4, 2025
dbb21f1
build site
DougManuel Jun 4, 2025
31b71e1
Merge pull request #134 from Big-Life-Lab/packyears-bug
DougManuel Jun 4, 2025
b71b313
Add github actions R-CMD-check.yaml
DougManuel Jun 5, 2025
bb903c6
Merge remote-tracking branch 'origin/main'
DougManuel Jun 5, 2025
9218792
feat: add YAML validation infrastructure
DougManuel Jun 29, 2025
4690c86
feat: add v2.2.0 variable enhancements
DougManuel Jun 29, 2025
468aa50
feat: enhance functions for v2.2.0 with _i cycle support
DougManuel Jun 29, 2025
6f4d2bb
feat: add comprehensive testing and documentation for v2.2.0
DougManuel Jun 29, 2025
0f5d328
feat: finalize v2.2.0 package metadata updates
DougManuel Jun 30, 2025
128e91e
feat: Commit current state of feature branch before haven migration
DougManuel Jul 1, 2025
7679a7e
fix: update schema validation naming and documentation
DougManuel Jul 1, 2025
73223df
feat: enhance variable metadata for v2.2.0
DougManuel Jul 1, 2025
4b730ac
feat: add structured @note versioning to v2.2.0 functions
DougManuel Jul 1, 2025
22947fe
feat: enhance schema validation and templates for v2.2.0
DougManuel Jul 1, 2025
cf090aa
feat: update version references from v2.2.0 to v3.0.0
DougManuel Jul 1, 2025
a6f313a
feat: add comprehensive derived variable development guide
DougManuel Jul 1, 2025
4306d18
feat: standardize derived variable documentation to R/Tidyverse conve…
DougManuel Jul 1, 2025
4b03cef
feat: complete alcohol function documentation and fix critical namesp…
DougManuel Jul 1, 2025
07c5a25
docs: update project status after documentation standardization
DougManuel Jul 1, 2025
cb5ebed
feat: modernize function names to R/Tidyverse conventions
DougManuel Jul 1, 2025
786d8a8
feat: update metadata and test files for function renaming
DougManuel Jul 1, 2025
94d1a92
feat: add backward compatibility aliases for v3.0.0 function renaming
DougManuel Jul 1, 2025
d0c1dc4
fix: correct test file source statements
DougManuel Jul 1, 2025
78e2c60
docs: update NAMESPACE and documentation for function renaming
DougManuel Jul 1, 2025
15fc75d
feat: add comprehensive version validation and metadata updates
DougManuel Jul 1, 2025
98591c1
feat: comprehensive integration testing and documentation enhancements
DougManuel Jul 1, 2025
0d94164
feat: complete pkgdown documentation for v3.0.0 function modernization
DougManuel Jul 1, 2025
80645a0
fix: physical activity documentation spacing
DougManuel Jul 1, 2025
3bb4aba
enhance: comprehensive rec_with_table testing across all major CCHS c…
DougManuel Jul 1, 2025
5cb28a8
fix: resolve R CMD check errors for GitHub Actions
DougManuel Jul 2, 2025
fb94417
fix: categorize_bmi type consistency for case_when compatibility
DougManuel Jul 2, 2025
3c2f335
fix: Comment out failing tests for legacy functions
DougManuel Jul 2, 2025
a6bf4ea
Remove docs/ folder from git tracking
DougManuel Jul 2, 2025
d8d5e76
Remove docs/ folder from git tracking
DougManuel Jul 2, 2025
ee6772f
Merge remote-tracking branch 'origin/feature/v3.0.0-validation-infras…
DougManuel Jul 2, 2025
1e3b3ee
Resolve merge conflicts with dev branch
DougManuel Jul 2, 2025
26e719f
feat: implement v3.0.0 validation infrastructure and modernize derive…
DougManuel Jul 4, 2025
db91be0
style: apply code formatting and final BMI validation fixes
DougManuel Jul 4, 2025
5eb4f16
docs: restore splice operator comments and development TODOs
DougManuel Jul 4, 2025
cf41b1d
feat: complete ADL functions v3.0.0 modernization with enhanced docum…
DougManuel Jul 5, 2025
4c1715d
feat: complete alcohol functions v3.0.0 modernization with comprehens…
DougManuel Jul 5, 2025
8c37bf9
feat: migrate alcohol functions to calculate_* naming convention
DougManuel Jul 6, 2025
a3b69eb
refactor: code quality improvements and styler formatting
DougManuel Jul 6, 2025
de14495
refactor: code quality improvements and styler formatting
DougManuel Jul 6, 2025
0089be3
Merge remote-tracking branch 'origin/feature/v3.0.0-validation-infras…
DougManuel Jul 6, 2025
227888e
refactor: modernize BMI function architecture and validation approach
DougManuel Jul 7, 2025
dd1f78b
Add smoking variable review/updates from Diasparra (PR#3, cchsflow-temp)
DougManuel Jul 9, 2025
9c777d1
additional files from mdiaspar re: smoking derived functions
DougManuel Jul 10, 2025
9dc3958
feat: restore BMI metadata and add range-based HWTGBMI_cat4
DougManuel Jul 12, 2025
ae098b2
Removes obsolete binary data files
DougManuel Jul 12, 2025
53044a4
Fix: Remove dangerous .GlobalEnv pollution from SMKG040 age functions
DougManuel Jul 12, 2025
aaeb783
Fix: Eliminate all remaining .GlobalEnv pollution and metadata loading
DougManuel Jul 12, 2025
843663b
Refactor: Convert age started functions to Pattern B (clean_variables…
DougManuel Jul 12, 2025
ab206c1
feat: Corrected smoking variable mappings, refactored bmi.R constants
DougManuel Jul 13, 2025
f8f0277
feat: variable_details.csv added: 4 X SMK ... _cont
DougManuel Jul 13, 2025
045ffac
feat: reorganize smoking status functions and add comprehensive tests
DougManuel Jul 14, 2025
6220e84
feat: All five smoking status variables completed
DougManuel Jul 14, 2025
82b9c63
feat: added smoking initiation functions and update variable_details
DougManuel Jul 14, 2025
c1a2a9d
fix: bmi.R
DougManuel Jul 14, 2025
7eb6072
Merge branch 'smoking-modernization-fix' into feature/v3.0.0-validati…
DougManuel Jul 14, 2025
57aba9c
update: variable_details.csv for smoking continuous variable
DougManuel Jul 18, 2025
9fdd927
feat: enhance schema validation and data consistency rules
DougManuel Jul 21, 2025
be360cc
feat: add comprehensive CSV validation infrastructure
DougManuel Jul 21, 2025
c625a2d
Merge branch 'smoking-modernization-fix' into feature/v3.0.0-validati…
DougManuel Jul 21, 2025
aeae50e
fixed bug with ADL_01 variable
Aug 29, 2025
35007e4
updated ADL_der variable
Aug 29, 2025
65b417e
updated ADL_score_5 variable
Aug 29, 2025
e724e82
updated CCC_181 variable
Aug 29, 2025
a562a2a
new harmonized variable, last time visited dental professional
Aug 29, 2025
b3ca31e
harmonzied new variable, self-perceived oral health
Aug 29, 2025
0220528
harmonized new variable, frequency teeth/gum pain
Aug 29, 2025
9be9b8f
harmonized new variable, has one or more of own teeth
Aug 29, 2025
ae18185
harmonized new variable, frequency of brushing teeth
Aug 29, 2025
801eb97
updates to the SMK_01B variable details. added row for it to variable…
Aug 29, 2025
e961c6e
updates to SMKG01C_A variable
Aug 29, 2025
352fe16
updates to the SMKG01C_B variable
Sep 4, 2025
4a25f8a
updates to the SMKG01C_cont variable
Sep 4, 2025
6f72805
Merge pull request #140 from Big-Life-Lab/oral-health-addition
yulric 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")'
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
.Ruserdata
*.DS_Store
docs/
..Rcheck/
19 changes: 14 additions & 5 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 <[email protected]>
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,12 @@ 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)
testthat (>= 3.0.0),
kableExtra,
DT,
rmarkdown,
knitr,
pkgdown
Config/testthat/edition: 3
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