Description Usage Arguments Details Value Author(s) See Also Examples
Get the extension of a vector of filenames, assuming that the extension is the set of characters that
follows the last "."
. A wrapper for grabLast
.
1 | getExtension(vec, split.char = ".")
|
vec |
Character vector (usually containing filenames) |
split.char |
A single character used to split the character strings |
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.
Character vector of filename extensions
Landon Sego
Additional functions for filename manipulations: stripExtension
, stripPath
,
getPath
, grabLast
, basename
, dirname
1 2 3 4 5 6 7 8 9 10 11 12 13 | getExtension(c(a = "this old file.doc",
b = "that young file.rtf",
c = "this.good.file.doc",
d = "this_bad_file",
e = "thisfile.",
f = NA,
g = "that.this.pdf",
h = ".", i = ""))
# An example with 'real' files
files <- dir(file.path(path.package(package = "Smisc"), "data"), full.names = TRUE)
print(files)
getExtension(files)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.