Learn R Programming

neurobase (version 1.32.4)

remap_filename: Build Filename (usually for images)

Description

This is a simple function that helps with the case where you want to construct a filename (usually for an image) with the same base of the filename, the same directory (default), but things added to the front or end of that base filename, with the same extension.

Usage

remap_filename(x, sub_dir = NULL, prefix = "", suffix = "")

Value

Character vector

Arguments

x

input filename/character vector

sub_dir

sub-directory for the new filename. If NULL, then the directory is the the same directory as x

prefix

string to put in front of base of filename

suffix

string to put at the end of base of filename

Examples

Run this code
fname = file.path("/path/to/file", "original.nii.gz")
remap_filename(fname, prefix = "preproc_", "_with_gz")
fname = "original.nii"
remap_filename(fname, prefix = "note_", "_has_directory")
remap_filename(c(fname, "other.nii.gz"), prefix = "note_", "_has_directory")

Run the code above in your browser using DataLab