Conversation
There was a problem hiding this comment.
Pull request overview
This PR addresses issue #13 by fixing the cadence band classification logic and implementing several infrastructure improvements. The main fix corrects the cut() function behavior in cadence band computation by setting right = FALSE and adjusting break points to properly classify step counts into their intended bands.
Changes:
- Fixed cadence band classification by updating break points and setting
right = FALSEin thecut()function - Renamed package from
rnhanescadencetocadenceacross all files - Changed default
group_colsparameter from hardcodedc("SEQN", "PAXDAYM")toNULLand introducednhanes_group_cols()helper function - Added comprehensive vignette documenting cadence computation functionality
- Updated utility function to handle NULL
group_colsparameter
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| R/cadence_bands.R | Core fix for band classification: updated breaks, added right = FALSE, removed fast_walk and very_fast_walk bands |
| R/nhanes_group_cols.R | New helper function returning default NHANES grouping columns |
| R/aaa_utils.R | Updated to handle NULL group_cols parameter |
| R/summarize_cadence.R | Changed group_cols default from hardcoded value to NULL |
| R/compute_peak_cadence.R | Changed group_cols default from hardcoded value to NULL |
| vignettes/calculate_cadence.Rmd | New vignette documenting cadence calculation workflow |
| tests/testthat/*.R | Updated test calls to explicitly pass group_cols parameter |
| tests/testthat.R | Updated library name from rnhanescadence to cadence |
| DESCRIPTION | Package rename and added vignette dependencies |
| man/*.Rd | Updated documentation for changed function signatures |
| .Rbuildignore | Updated for new package name |
| .gitignore | Added inst/doc to ignore vignette build output |
| vignettes/.gitignore | Added to ignore vignette build artifacts |
| cadence.Rproj | New RStudio project file for renamed package |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| - `mean_censored_cadence`: Mean cadence with censoring based on counts. | ||
| - `peak_1min`: Peak 1-minute cadence. | ||
| - `peak_30min`: Peak 30-minute cadence. | ||
| - `peak_60min`: Peak 30-minute cadence. |
There was a problem hiding this comment.
The description for peak_60min incorrectly says "Peak 30-minute cadence" when it should say "Peak 60-minute cadence".
| - `peak_60min`: Peak 30-minute cadence. | |
| - `peak_60min`: Peak 60-minute cadence. |
| - `zero`: Time spent in zero cadence band. | ||
| - `incidental`: Time spent in incidental cadence band. | ||
| - `sporadic`: Time spent in sporadic cadence band. | ||
| - `purposeful`: Time spent in purposeful cadence band. | ||
| - `slow_walk`: Time spent in slow walking cadence band. | ||
| - `medium_walk`: Time spent in medium walking cadence band. | ||
| - `brisk_walk`: Time spent in brisk walking cadence band. | ||
| - `fast_walk`: Time spent in fast walking cadence band: 90-99 steps/min. | ||
| - `very_fast_walk`: Time spent in very fast walking cadence band: 100-119 steps/min. | ||
| - `all_out`: Time spent in all-out cadence band: 119+ steps/min. | ||
|
|
||
|
|
There was a problem hiding this comment.
The documentation lists fast_walk and very_fast_walk as separate cadence bands with specific ranges (90-99 and 100-119 steps/min), but these bands were removed from the code. The actual bands now only include "zero", "incidental", "sporadic", "purposeful", "slow_walk", "medium_walk", "brisk_walk", and "all_out" (8 bands total), with breaks at [0, 1), [1, 20), [20, 40), [40, 60), [60, 80), [80, 100), [100, 120), and [120, Inf). The documentation should be updated to reflect the actual implemented bands and their ranges.
| - `zero`: Time spent in zero cadence band. | |
| - `incidental`: Time spent in incidental cadence band. | |
| - `sporadic`: Time spent in sporadic cadence band. | |
| - `purposeful`: Time spent in purposeful cadence band. | |
| - `slow_walk`: Time spent in slow walking cadence band. | |
| - `medium_walk`: Time spent in medium walking cadence band. | |
| - `brisk_walk`: Time spent in brisk walking cadence band. | |
| - `fast_walk`: Time spent in fast walking cadence band: 90-99 steps/min. | |
| - `very_fast_walk`: Time spent in very fast walking cadence band: 100-119 steps/min. | |
| - `all_out`: Time spent in all-out cadence band: 119+ steps/min. | |
| - `zero`: Time spent in zero cadence band: 0 steps/min. | |
| - `incidental`: Time spent in incidental cadence band: 1-19 steps/min. | |
| - `sporadic`: Time spent in sporadic cadence band: 20-39 steps/min. | |
| - `purposeful`: Time spent in purposeful cadence band: 40-59 steps/min. | |
| - `slow_walk`: Time spent in slow walking cadence band: 60-79 steps/min. | |
| - `medium_walk`: Time spent in medium walking cadence band: 80-99 steps/min. | |
| - `brisk_walk`: Time spent in brisk walking cadence band: 100-119 steps/min. | |
| - `all_out`: Time spent in all-out cadence band: 120+ steps/min. |
| Cadence Bands: | ||
| - `zero`: Time spent in zero cadence band. | ||
| - `incidental`: Time spent in incidental cadence band. | ||
| - `sporadic`: Time spent in sporadic cadence band. | ||
| - `purposeful`: Time spent in purposeful cadence band. | ||
| - `slow_walk`: Time spent in slow walking cadence band. | ||
| - `medium_walk`: Time spent in medium walking cadence band. | ||
| - `brisk_walk`: Time spent in brisk walking cadence band. | ||
| - `fast_walk`: Time spent in fast walking cadence band: 90-99 steps/min. | ||
| - `very_fast_walk`: Time spent in very fast walking cadence band: 100-119 steps/min. | ||
| - `all_out`: Time spent in all-out cadence band: 119+ steps/min. |
There was a problem hiding this comment.
The documentation for cadence bands (lines 61-67) does not specify the step ranges for each band. Since the code now uses specific break points [0, 1, 20, 40, 60, 80, 100, 120, Inf] with right = FALSE, the documentation should clearly state the ranges for each band to help users understand the classification (e.g., zero: 0 steps/min, incidental: 1-19 steps/min, sporadic: 20-39 steps/min, etc.).
| Cadence Bands: | |
| - `zero`: Time spent in zero cadence band. | |
| - `incidental`: Time spent in incidental cadence band. | |
| - `sporadic`: Time spent in sporadic cadence band. | |
| - `purposeful`: Time spent in purposeful cadence band. | |
| - `slow_walk`: Time spent in slow walking cadence band. | |
| - `medium_walk`: Time spent in medium walking cadence band. | |
| - `brisk_walk`: Time spent in brisk walking cadence band. | |
| - `fast_walk`: Time spent in fast walking cadence band: 90-99 steps/min. | |
| - `very_fast_walk`: Time spent in very fast walking cadence band: 100-119 steps/min. | |
| - `all_out`: Time spent in all-out cadence band: 119+ steps/min. | |
| Cadence Bands (steps per minute, using breaks [0, 1, 20, 40, 60, 80, 100, 120, Inf] with `right = FALSE`): | |
| - `zero`: Time spent at 0 steps/min. | |
| - `incidental`: Time spent at 1–19 steps/min. | |
| - `sporadic`: Time spent at 20–39 steps/min. | |
| - `purposeful`: Time spent at 40–59 steps/min. | |
| - `slow_walk`: Time spent at 60–79 steps/min. | |
| - `medium_walk`: Time spent at 80–99 steps/min. | |
| - `brisk_walk`: Time spent at 100–119 steps/min. | |
| - `all_out`: Time spent at 120+ steps/min. |
|
Can you comment @ang-zhao on this vs. not |
This is to address #13 but I'm not sure if this is the right classification given what @ang-zhao envisioned or implemented