stripPath {Smisc}R Documentation

Remove the path from a vector of filenames

Description

Remove the path from a vector of filenames

Usage

stripPath(vec)

Arguments

vec

Character vector (usually containing filenames)

Details

Assumes paths are delineated using forward slashes. If an NA is supplied, then an NA is returned. If the desired string doesn't exist (see examples below), a "" is returned.

Value

Character vector with leading path removed from the filenames

Author(s)

Landon Sego

See Also

Additional functions for filename manipulations: stripExtension, getExtension, getPath, grabLast, basename, dirname

Examples

stripPath(c(a = "this.good.path/filename.R", b = "nopath.R", c = "/", d = NA,
            e = "only.paths.1/only.paths.2/", ""))

# An example with 'real' files
files <- dir(file.path(path.package(package = "Smisc"), "data"), full.names = TRUE)
print(files)
stripPath(files)
stripPath(stripExtension(files))

[Package Smisc version 0.3.9.1 Index]