The hardware and bandwidth for this mirror is donated by METANET, the Webhosting and Full Service-Cloud Provider.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]metanet.ch.

SafeMapper pkgdown

R-CMD-check CRAN status r-universe License: MIT

Fault-Tolerant Functional Programming with Automatic Checkpointing

Never lose your computational progress again.

Quick Start β€’ Reference β€’ Tutorials β€’ Changelog


🎯 The Problem

Long-running computations in R are vulnerable to interruptions:

# Processing 10,000 API calls...
result <- purrr::map(urls, fetch_data)
# ❌ Crashes at item 9,847 after 3 hours
# ❌ All progress lost
# ❌ Must restart from scratch

Common failure scenarios: - R session crashes or runs out of memory - Network timeouts during API calls - System restarts or power failures - Accidental interruption (Ctrl+C)

βœ… The Solution

SafeMapper provides drop-in replacements for purrr and furrr functions with automatic checkpoint-based recovery:

# Same code, but fault-tolerant
result <- s_map(urls, fetch_data)
# ⚑ Crashes at item 9,847...

# Just re-run the same code:
result <- s_map(urls, fetch_data)
# βœ… "Resuming from checkpoint: 9800/10000 items completed"
# βœ… Continues from where it left off
# βœ… No configuration needed

πŸ“¦ Installation

# From r-universe (recommended)
install.packages("SafeMapper", repos = "https://zaoqu-liu.r-universe.dev")

# From GitHub
devtools::install_github("Zaoqu-Liu/SafeMapper")

πŸš€ Quick Start

library(SafeMapper)

# Replace purrr::map() with s_map() - that's it!
results <- s_map(1:1000, function(x) {
  Sys.sleep(0.1)  # Simulate slow operation
  x^2
})

# If interrupted, just re-run - automatic recovery!

πŸ“– See full tutorial: Quick Start Guide


⭐ Key Features

Feature Description Learn More
Zero Configuration Works out of the box - no setup required Quick Start
Automatic Recovery Detects previous runs and resumes automatically Core Concepts
Drop-in Replacement Same API as purrr and furrr Map Functions
Transparent Checkpointing Progress saved at configurable intervals Session Management
Parallel Support Full furrr compatibility for parallel processing Parallel Processing
Robust Error Handling Built-in retry and error capture Error Handling

πŸ”§ Function Reference

Sequential Processing (purrr replacements)

SafeMapper purrr Returns Docs
s_map() map() list πŸ“–
s_map_chr() map_chr() character πŸ“–
s_map_dbl() map_dbl() numeric πŸ“–
s_map_int() map_int() integer πŸ“–
s_map_lgl() map_lgl() logical πŸ“–
s_map_dfr() map_dfr() data.frame (row-bind) πŸ“–
s_map_dfc() map_dfc() data.frame (col-bind) πŸ“–
s_map2() map2() list (two inputs) πŸ“–
s_pmap() pmap() list (multiple inputs) πŸ“–
s_imap() imap() list (with index) πŸ“–
s_walk() walk() side effects πŸ“–

Parallel Processing (furrr replacements)

SafeMapper furrr Docs
s_future_map() future_map() πŸ“–
s_future_map2() future_map2() πŸ“–
s_future_pmap() future_pmap() πŸ“–
s_future_walk() future_walk() πŸ“–
s_future_imap() future_imap() πŸ“–

All variants (_chr, _dbl, _int, _lgl, _dfr, _dfc) are supported.

Error Handling

SafeMapper purrr Description Docs
s_safely() safely() Capture errors πŸ“–
s_possibly() possibly() Return default on error πŸ“–
s_quietly() quietly() Capture messages/warnings πŸ“–

πŸ“š Full API Reference: Reference Index


βš™οΈ Configuration

# Optional: customize settings
s_configure(

  batch_size = 100,      # Items per checkpoint (default: 100)
  retry_attempts = 3     # Retry failed batches (default: 3)
)

# Clean old checkpoint files
s_clean_sessions(older_than_days = 7)

πŸ“– Learn more: Session Management Guide


πŸ”„ How It Works

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    First Execution                          β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  Input Data  ──►  Fingerprint  ──►  Process Batches        β”‚
β”‚     [1:1000]       "abc123..."      [1-100] βœ“ checkpoint   β”‚
β”‚                                     [101-200] βœ“ checkpoint β”‚
β”‚                                     [201-300] βœ— CRASH!     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    Re-execution                             β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  Input Data  ──►  Fingerprint  ──►  Find Checkpoint        β”‚
β”‚     [1:1000]       "abc123..."      "200 items completed"  β”‚
β”‚                                                             β”‚
β”‚                    Resume from 201  ──►  Complete!         β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
  1. Fingerprinting: Each task is identified by a hash of input data characteristics
  2. Checkpointing: Results are saved to disk at batch intervals
  3. Recovery: On re-run, matching fingerprints trigger automatic restoration
  4. Cleanup: Checkpoints are removed after successful completion

πŸ“– Deep dive: Core Concepts & Architecture


πŸ’Ό Use Cases

Use Case Description Example
API Data Collection Web scraping, REST API calls with rate limits View Example
File Processing ETL pipelines, batch transformations View Example
Machine Learning Cross-validation, hyperparameter tuning View Example
Web Scraping Extracting data from thousands of pages View Example
Bioinformatics Processing large genomic datasets View Example
Database Migration Moving data between systems View Example

πŸ“– All examples: Real-World Examples


πŸ“š Documentation & Tutorials

Getting Started

Tutorial Description Time
πŸš€ Quick Start Get up and running 5 min
🧠 Core Concepts Understand the architecture 15 min

Function Guides

Tutorial Description Level
πŸ—ΊοΈ Map Functions Complete guide to all s_map variants Intermediate
⚑ Parallel Processing Speed up with s_future_map Intermediate
πŸ›‘οΈ Error Handling s_safely, s_possibly, s_quietly Intermediate
πŸ“‹ Session Management Configure and manage checkpoints Intermediate

Advanced Topics

Tutorial Description Level
🎯 Real-World Examples Complete production examples Advanced
πŸ† Best Practices Production patterns & anti-patterns Advanced

🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request or open an Issue.

πŸ‘€ Author

Zaoqu Liu
- πŸ“§ Email: liuzaoqu@163.com
- πŸ™ GitHub: @Zaoqu-Liu - πŸ”¬ ORCID: 0000-0002-0452-742X

πŸ“„ License

MIT Β© 2026 Zaoqu Liu


Documentation β€’ Report Bug β€’ Request Feature

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.