Complete the extension of a file (.r or .R).

complete_extension(name, base = NULL)

Arguments

name

character. The filename sans extension.

base

character. A base path to be prefixed to name when checking if the suffixed versions exist. The final returned string will not include this base.

Value

name suffixed by ".r" or ".R" according to which exists. (Many Unix-based systems are extension case-sensitive).

Note

This function assumes at least one file ending in .r or .R exists.

Examples

not_run({ # Assume we have a file \code{"foo.R"}. stopifnot(complete_extension("foo") == "foo.R") # Assume we have a file \code{"bar.r"}. stopifnot(complete_extension("bar") == "bar.R") })