standardize_path

0th

Percentile

Standardize paths

Standardi[sz]e path names so that they can be more easily compared.

Usage
standardize_path(x = dir(), sep = c("/", "\\"), include_names = TRUE)
standardise_path(x = dir(), sep = c("/", "\\"), include_names = TRUE)
Arguments
x
A character vector of file paths. Defaults to files in the current directory.
sep
String separator between directory levels in the output.
include_names
A logical value indicating whether the output should be named with the input file paths.
Details

standardize_path wraps normalizePath, providing additional tweaks to the output.

  • Missing inputs always return NA_character_.
  • Leading double back slashes are preserved under all OSes regardless of the values of sep.
  • Leading double forward slashes are converted to double back slash under Windows (they are likely UNC paths), and a single forward slash under Unixes (they are likely absolute paths).
  • Other back and forward slashes are replaced by sep.
  • Paths are always made absolute.
  • Trailing slashes are always stripped, except for root ("/") and Windows drives ("C:/", etc.).
  • Windows drives are always capitalized.

Value

A character vector of paths, pointing to the same locations as the input, but in a standardized form.

See Also

normalizePath, path.expand, file_path_as_absolute, getAbsolutePath

Aliases
  • standardise_path
  • standardize_path
Examples
standardize_path(c(".", "..", "~", R.home(), NA))
standardize_path(c(".", "..", "~", R.home(), NA), "\\")
Documentation reproduced from package pathological, version 0.1-1, License: Unlimited

Community examples

Looks like there are no examples yet.