Thank you for your interest in contributing to the completejourney package! This document provides guidelines and instructions for contributing to the project.
Install the required development packages:
install.packages(c("devtools", "roxygen2", "testthat", "usethis", "pkgdown", "rhub"))
devtools::load_all()All exported functions must be documented using roxygen2 comments. Add special comment blocks above your function:
#' Function title (one line)
#'
#' Detailed description of what the function does.
#' Can span multiple lines.
#'
#' @param param1 Description of first parameter
#' @param param2 Description of second parameter
#'
#' @return Description of what the function returns
#'
#' @examples
#' my_function(param1 = "value", param2 = 10)
#'
#' @export
my_function <- function(param1, param2) {
# Function code here
}After making changes to function documentation, regenerate the .Rd files:
# Generate documentation from roxygen2 comments
devtools::document()Preview documentation for a specific function:
# Preview help file
?my_functionUpdate the pkgdown site to see documentation changes on the website:
# Build the pkgdown website
pkgdown::build_site()Run all tests locally:
# Run all tests (recommended - uses devtools)
devtools::test()
# Alternative: run all tests using testthat directly
testthat::test_package("completejourney")
# Run specific test file
testthat::test_file("tests/testthat/test_downloads.R")Note: devtools::test() is the recommended approach as it automatically loads the package and handles the testing environment properly. Use testthat functions directly only when you need more control over the testing process.
tests/testthat/
skip_on_cran() for tests that require internet connectivityskip_on_ci() for tests that shouldn’t run in continuous integrationtest_*.R
test_that() blocksBefore submitting a pull request, run a full package check:
# Comprehensive local check (recommended)
devtools::check()
# For CRAN submission: use --as-cran flag for stricter checks
devtools::check(args = "--as-cran")This should return: 0 errors ✓ | 0 warnings ✓ | 0 notes ✓
When to use --as-cran: - Use devtools::check() for regular development and pull requests - Use devtools::check(args = "--as-cran") when preparing for CRAN submission (performs additional checks like CRAN does)
Before major releases or CRAN submissions, test on multiple platforms:
# Check on Windows (R-devel)
devtools::check_win_devel()
# Check on Windows (R-release)
devtools::check_win_release()
# Check on Windows (R-oldrelease)
devtools::check_win_oldrelease()
# Automated CRAN platform checks
rhub::check_for_cran()
# Or specify specific platforms
rhub::check(platform = c(
"ubuntu-gcc-release",
"windows-x86_64-devel",
"macos-highsierra-release-cran"
))You’ll receive email notifications with the results.
For maintainers preparing a CRAN submission:
# 1. Update version number in DESCRIPTION
usethis::use_version()
# 2. Update NEWS.md with changes
# 3. Generate documentation
devtools::document()
# 4. Build pkgdown site
pkgdown::build_site()
# 5. Run local check with CRAN settings
devtools::check(args = "--as-cran")
# 6. Check on win-builder
devtools::check_win_devel()
devtools::check_win_release()
# 7. Check on R-hub
rhub::check_for_cran()
# 8. Update cran-comments.md with test results
# 9. Submit to CRAN
devtools::release()The package datasets are generated from raw CSV files. To rebuild them:
source("data-raw/prep-data.R")Note: This requires the raw CSV files from 84.51° at the hardcoded path ../../Data sets/Complete_Journey_UV_Version/
.rda files in data/ and bundled with the package.rds files on GitHub and downloaded on demand via get_transactions(), get_promotions(), and get_data()
devtools::check() and ensure it passesIf you have questions or encounter issues:
r and completejourney tags