- Home
- CRAN
**Smisc**: Sego Miscellaneous**getExtension**: Get the extension of a vector of filenames

# Get the extension of a vector of filenames

### Description

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`

.

### Usage

1 | ```
getExtension(vec, split.char = ".")
``` |

### Arguments

`vec` |
Character vector (usually containing filenames) |

`split.char` |
A single character used to split the character strings |

### 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 of filename extensions

### Author(s)

Landon Sego

### See Also

Additional functions for filename manipulations: `stripExtension`

, `stripPath`

,
`getPath`

, `grabLast`

, `basename`

, `dirname`

### Examples

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)
``` |

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker. Vote for new features on Trello.

- allMissing: Identifies missing rows or columns in a data frame or matrix
- allMissing: Identifies missing rows or columns in a data frame or matrix
- as.numericSilent: Convert any vector to numeric, if possible
- as.numericSilent: Convert any vector to numeric, if possible
- comboList: Produces all possible combinations of a set of linear model...
- comboList: Produces all possible combinations of a set of linear model...
- cumMax: Computes the maximum of the vector up to the current index
- cumMax: Computes the maximum of the vector up to the current index
- cumsumNA: Computes the cummulative sum of a vector without propagating...
- cumsumNA: Computes the cummulative sum of a vector without propagating...
- cusum: Calculates a sequence of Cusum statistics
- cusum: Calculates a sequence of Cusum statistics
- dataIn: A flexible way to import data into R.
- dataIn: A flexible way to import data into R.
- df2list: Row-wise conversion of a data frame to a list
- df2list: Row-wise conversion of a data frame to a list
- dfplapply: Parallelized single row processing of a data frame
- dfplapply: Parallelized single row processing of a data frame
- dframeEquiv: Examines the equivalence of two dataframes or matrices
- dframeEquiv: Examines the equivalence of two dataframes or matrices
- dkbinom: Probability functions for the sum of k independent binomials
- dkbinom: Probability functions for the sum of k independent binomials
- doCallParallel: Call a function with a vectorized input in parallel
- doCallParallel: Call a function with a vectorized input in parallel
- factor2character: Converts all factor variables in a dataframe to character...
- factor2character: Converts all factor variables in a dataframe to character...
- factor2numeric: A simple function for converting factors to numeric values
- factor2numeric: A simple function for converting factors to numeric values
- findDepMat: Identify linearly dependent rows or columns in a matrix
- findDepMat: Identify linearly dependent rows or columns in a matrix
- formatDT: Converts date or datetime strings into alternate formats
- formatDT: Converts date or datetime strings into alternate formats
- generics: Generic for 'signal'
- generics: Generic for 'signal'
- getExtension: Get the extension of a vector of filenames
- getExtension: Get the extension of a vector of filenames
- getPath: Get the path of a vector of filenames
- getPath: Get the path of a vector of filenames
- grabLast: Get the final set of characters after a single-character...
- grabLast: Get the final set of characters after a single-character...
- hardCode: Facilitate hard coding constants into R
- hardCode: Facilitate hard coding constants into R
- hpd: Calculate the highest posterior density credible interval for...
- hpd: Calculate the highest posterior density credible interval for...
- integ: Simple numerical integration routine
- integ: Simple numerical integration routine
- linearMap: Linear mapping of a numeric vector or scalar
- linearMap: Linear mapping of a numeric vector or scalar
- list2df: Convert a list to a data frame
- list2df: Convert a list to a data frame
- loadObject: Loads and returns the object(s) in one or more ".Rdata" files
- loadObject: Loads and returns the object(s) in one or more ".Rdata" files
- more: Display the contents of a file to the R console
- more: Display the contents of a file to the R console
- movAvg2: Calculate the moving average using a 2-sided, symmetric...
- movAvg2: Calculate the moving average using a 2-sided, symmetric...
- openDevice: Opens a graphics device based on the filename extension
- openDevice: Opens a graphics device based on the filename extension
- padZero: Pad a vector of numbers with zeros
- padZero: Pad a vector of numbers with zeros
- parLapplyW: A wrapper for parLapply
- parLapplyW: A wrapper for parLapply
- parseJob: Parses a collection of elements into (almost) equal-sized...
- parseJob: Parses a collection of elements into (almost) equal-sized...
- pcbinom: A continuous version of the binomial cdf
- pcbinom: A continuous version of the binomial cdf
- pddply: Parallel wrapper for plyr::ddply
- pddply: Parallel wrapper for plyr::ddply
- plapply: Simple parallelization of lapply
- plapply: Simple parallelization of lapply
- plotFun: Plot one or more functions on a single plot
- plotFun: Plot one or more functions on a single plot
- PowerData: An example of power data
- PowerData: An example of power data
- pvar: Prints the name and value of one or more objects
- pvar: Prints the name and value of one or more objects
- qbind: Quickly row and column bind many objects together at once
- qbind: Quickly row and column bind many objects together at once
- rma: Remove all objects from the global environment
- rma: Remove all objects from the global environment
- select: Select rows or columns from data frames or matrices while...
- select: Select rows or columns from data frames or matrices while...
- selectElements: Validate selected elements from a character vector
- selectElements: Validate selected elements from a character vector
- sepList: Separate a list into distinct objects
- sepList: Separate a list into distinct objects
- smartFilter: Calculate a moving dot product (or filter) over a numeric...
- smartFilter: Calculate a moving dot product (or filter) over a numeric...
- smartRbindMat: Row bind matrices whose column names may not be the same
- smartRbindMat: Row bind matrices whose column names may not be the same
- smartTimeAxis: Produces a time axis with smart spacing
- smartTimeAxis: Produces a time axis with smart spacing
- Smisc-package: Smisc: Sego Miscellaneous
- Smisc-package: Smisc: Sego Miscellaneous
- sourceDir: Sources all files with '.R' or '.r' extensions in a directory
- sourceDir: Sources all files with '.R' or '.r' extensions in a directory
- stopifnotMsg: Check multiple conditions and return coresponding error...
- stopifnotMsg: Check multiple conditions and return coresponding error...
- stripExtension: Remove the extension of a vector of filenames
- stripExtension: Remove the extension of a vector of filenames
- stripPath: Remove the path from a vector of filenames
- stripPath: Remove the path from a vector of filenames
- timeData: Generic data frame with a time variable
- timeData: Generic data frame with a time variable
- timeDiff: Subtracts two time series by matching irregular time indexes
- timeDiff: Subtracts two time series by matching irregular time indexes
- timeDiff.eg: Four short time series
- timeIntegration: Approximate the integral of a vector of data over time
- timeIntegration: Approximate the integral of a vector of data over time
- timeIt: Times the execution of an expression.
- timeIt: Times the execution of an expression.
- timeStamp: Embeds the present datetime into a file name
- timeStamp: Embeds the present datetime into a file name
- umvueLN: Computes UMVUEs of lognormal parameters
- umvueLN: Computes UMVUEs of lognormal parameters
- vertErrorBar: Draw vertical error bar(s) on a plot
- vertErrorBar: Draw vertical error bar(s) on a plot