str_give_ext {strex} | R Documentation |
Ensure a file name has the intended extension.
Description
Say you want to ensure a name is fit to be the name of a csv file. Then, if the input doesn't end with ".csv", this function will tack ".csv" onto the end of it. This is vectorized over the first argument.
Usage
str_give_ext(string, ext, replace = FALSE)
Arguments
string |
The intended file name. |
ext |
The intended file extension (with or without the "."). |
replace |
If the file has an extension already, replace it (or append the new extension name)? |
Value
A string: the file name in your intended form.
Examples
str_give_ext(c("abc", "abc.csv"), "csv")
str_give_ext("abc.csv", "pdf")
str_give_ext("abc.csv", "pdf", replace = TRUE)
[Package strex version 2.0.0 Index]