Executes an R script as part of a data processing pipeline, with optional logging to file and execution time tracking.
Details
This function:
Prints the step label and timing information to console
Creates a timestamped log file in
2_pipeline/logs/directoryRedirects both standard output and messages to the log file
Sources (executes) the specified script from
code_dirCalculates and displays the execution duration
Automatically closes log file connections via
on.exit()
Log files are named using the pattern:
YYYY-MM-DD_HH-MM-SS_<sanitized_label>.log
Label sanitization converts non-alphanumeric characters to
underscores.
Note
Requires the global variable code_dir to be defined. Requires the
function format_time_diff() to be available. Logging is controlled
by the enable_logging variable.