Skip to contents

Introduction

devkit is a zero-dependency toolkit designed to assist R package developers and data scientists in maintaining high standards of code quality, session reproducibility, and system efficiency.

This guide provides an overview of the toolkit’s core modules and how to integrate them into your workflow.

📦 Package Development Workflow

Dependency Management

Maintaining a clean DESCRIPTION file is critical for CRAN compliance.

Scaffolding & Automation

Reduce boilerplate and avoid manual errors with automated generators.

🛡️ Session Auditing & Reproducibility

State Management

Ensure your scripts don’t leave the user’s environment in a messy state.

  • audit_script(): Captures the state of options(), par(), and getwd() before and after a script runs, prompting you to revert changes.
  • detect_masking(): Identifies when functions from different packages share the same name and helps you lock in the priority.
  • export_snapshot(): Creates a script to recreate your current session’s package environment.

Reproducibility Testing

  • simulate_clean_room(): Runs your script in a completely vanilla R session (--vanilla) to ensure it doesn’t rely on hidden local state.
  • benchmark_branches(): Compares the execution time of a script across different Git branches to quantify performance gains.

🧹 System & Memory Optimization

Memory Cleanup

Prevent R from crashing during large-scale data processing.

  • sweep_memory(): Interactively identifies and removes large objects from the global environment.
  • hunt_zombies(): Cleans up orphaned graphics devices and temporary files.
  • sweep_temp_cache(): Flushes hidden temporary caches (e.g., knitr, raster).

Safe Processing

  • loop_guardian(): Wraps long loops with a memory monitor that alerts you before you hit your RAM limit.
  • dispatch_checkpoints(): Implements a save-and-resume system for batch processing, protecting your work from crashes.

🔐 Data Privacy & Documentation

Anonymization

  • mask_identity(): A guided workflow to scramble or drop PII columns in a dataframe while preserving statistical distributions.

Documentation

  • dictate_dictionary(): Interactively generates a roxygen2 @format block for your datasets, ensuring your data dictionaries are professional and complete.

🌐 Network Utilities

  • network_diplomat(): A wrapper for network requests that implements exponential backoff and respects rate limits (HTTP 429).

Summary Table

Module Key Function Primary Goal
Meta architect_release() Versioning & News
Audit audit_dependencies() CRAN Compliance
State audit_script() Session Integrity
Memory hunt_zombies() Resource Cleanup
Privacy mask_identity() PII Anonymization
Batch dispatch_checkpoints() Crash Resilience
Perf benchmark_branches() Branch Comparison
Clean remove_user_installed_packages() Env Reset