latest_rds: Find the Most Recent .rds File Matching a Pattern

View source: R/leff_calibration_io.R

latest_rdsR Documentation

Find the Most Recent .rds File Matching a Pattern

Description

Scans output_dir for files matching the given prefix pattern and returns the path to the most recently modified one. Date-stamped filenames (e.g., results_20260402.rds) sort naturally, but this function uses filesystem modification time for robustness.

Usage

latest_rds(prefix, output_dir = "_data", verbose = TRUE)

Arguments

prefix

Character. Filename prefix to match (e.g., "selection_survival_frontier").

output_dir

Character. Directory to scan. Default: "_data".

verbose

Logical. Print the matched file. Default: TRUE.

Value

Full path to the most recent matching file, or NULL if no match is found.

Examples

## Not run: 
path <- latest_rds("selection_survival_frontier")
res  <- readRDS(path)

path <- latest_rds("calibration_binary_leff_grid")

## End(Not run)


forestsearch documentation built on Nov. 15, 2026, 9:06 a.m.