file_ext: Reimport/Renaming of tools Package's File Extension Functions

Description Usage Arguments Value Examples

Description

The tools package has file_ext related functions but the package has to be explicitly loaded (though comes standard with R) and the file_path_sans_ext is longer to type. The functions have been reimported and renamed to aid in their availablity with other path parsing tools to make their integration seamless (particularly in a pipeable form).

Usage

1
2
3
file_ext(x)

no_file_ext(x, compression = FALSE)

Arguments

x

A character vector giving file paths.

compression

logical. Should compression extension ‘.gz’, ‘.bz2’ or ‘.xz’ be removed first?

Value

Returns a character string with just the file extension (file_ext) or the path without the file extension (no_file_ext).

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
## Not run: 
library(magrittr)
(r_files <- dir(file.path(R.home(), "doc/manual"), full.names = TRUE))

file_ext(r_files)
no_file_ext(r_files)

r_files %>%
    parse_path() %>%
    back() %>%
    no_file_ext()

## End(Not run)

trinker/pathr documentation built on May 31, 2019, 9:41 p.m.