filename {filenamer}R Documentation

Create a filename.

Description

This function creates a filename object with a file path, tags, extensions, date stamp or date-time stamp.

Usage

filename(
  x,
  path = NULL,
  tag = NULL,
  ext = NULL,
  date = NULL,
  time = NULL,
  subdir = TRUE
)

Arguments

x

file name stem

path

path to the file

tag

tags for the file name

ext

file extension

date

date stamp (character or Date)

time

time stamp (character or POSIXct)

subdir

whether to append a date/time stamped subdirectory to path

Details

The date and time parameters can be specified as character vectors or date/time objects. If time is given as a POSIXct, it will override date. If these parameters are both NULL, automated date and time stamping may be done and is controlled by getOption("filenamer.timestamp"). If this option is NULL, 0, or less, no date or time stamping will be done; if it is 1, only date stamping will be done; if it is 2 or greater, date-time stamping will be done (default). Set date or time to NA to suppress date or time stamping for a particular filename. Stamps are shown in ISO 8601 date format ( ( platforms and are thus omitted; hyphens are omitted from date-time stamps for brevity.

By default, a date stamped subdirectory is appended to the file path. To disable this behaviour, set subdir to FALSE or disable path stamping globally by options(filenamer.path.timestamp = 0). This option is similar to filenamer.timestamp above.

Value

a filename object

Examples

# file name is date-time stamped and put in subdirectory by default
fn <- filename("data", tag="qc", ext="txt")
print(as.character(fn))

# disable date-time stamping and subdirectory insertion
fn2 <- filename("data", tag="qc", date=NA, time=NA, subdir=FALSE)
print(as.character(fn2))

# creating a new file name from an existing one yields a new time stamp
fn3 <- filename(fn)
print(as.character(fn3))


[Package filenamer version 0.2.4 Index]