buildFileName: Sequentially numbered file name creator

Description Usage Arguments Details Value Examples

View source: R/utils.R

Description

Useful functions that create sequentially numbered file names.

Usage

1
2
3
buildFileNameFun(..., prefix = "ponto", ext = ".rda", sep = "-")

buildFileName(n, prefix = "ponto", ext = NULL, sep = "-", nc = NULL)

Arguments

prefix

Prefix of the filename.

ext

File name extension. If NULL, use no extension.

sep

Separator element between different parts of the file name

n

Numbers used to build file name.

nc

Number of characters to use when building the numbers. If null use largest number in n.

Details

It is very common useful to build file names with sequential numbers within. So that the numbers appear in the correct order in directory listings or simply that when viewing the file names they appear homogeneous it is nice to have a function that perform build this file names easily. buildFileName takes as input a sequence of numbers and builds the file names with given prefix, extension and separator.

The other function, buildFileNameFun returns a function that creates the file name given the indexes. It allows multiple indexes so that, for instance a grid of file names can be created.

Value

Character vector with the names.

Examples

1
2
3
4
print(buildFileName(1:10, ext='.txt'))
print(buildFileName(1:10, ext='.txt', sep='_'))
print(buildFileName(1:10, ext=NULL))
print(buildFileName(1:10, nc=3))

tunelipt/wutils documentation built on Nov. 5, 2019, 11:01 a.m.