Creates a file name using the standardized format 'PROJECT-SXX-Description-YYYY_MM_DD-HH_MM.ext' where 'PROJECT' is a abbreviation for a project name, and 'SXX' is a letter followed by a number indicating the script or analysis index. Both variables can be automatically specified from existing environmental variables.

make_file_name(
  description,
  extension,
  project = NULL,
  script = NULL,
  date_time = NULL,
  remove = FALSE,
  path = ".",
  env_variables = c("ABBR_PROJECT", "ABBR_SCRIPT")
)

Arguments

description

A character string, a human-readable description of the file (with words typically separated by '_').

extension

A character string, the file extension (e.g., 'R', 'RData') - the period is added automatically.

project

A character string, the abbreviation for the project name (can be inferred from environmental variables).

script

A character string, typically a one-letter abbreviation followed by a two-digit number indicating the script or analysis index.

date_time

A character string giving the date and time (usually in the format 'YYYY_MM_DD-HH_MM') - if not provided uses the current date and time instead.

remove

Logical; if TRUE removes any existing files in the working directory with the same project, script, description, and extension values.

path

A character string specifying the subfolder(s) for the file.

env_variables

A character vector specifying the name of the environmental variables with the project and script abbreviations.

Value

A character string.

Examples


make_file_name( 'Example', 'R' )
#> [1] "Example-2024_10_19-11_24.R"
make_file_name( 'Example_2', 'RData', project = 'EX', script = 'S01' )
#> [1] "EX-S01-Example_2-2024_10_19-11_24.RData"