parent_dir: Get the parent dir

Description Usage Arguments Value Note Examples

Description

Gets the parent directory of the input.

Usage

1
parent_dir(x = ".", sep = c("/", "\\"))

Arguments

x

A character vector of file paths.

sep

String separator between directory levels in the output.

Value

A character vector of parent directories of the input.

Note

Missing values are returned as missing. On Windows, the parent of a drive, e.g., "c:/" is itself. Likewise, under Unix, the parent of "/" is itself.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
(x <- c(
  sys_which("R"),
  r_home(),
  r_profile_site(),
  "c:/",  # different behaviour under Windows/Unix
  "~",
  "/",
  "foo/bar/nonexistent",
  NA
))
parent_dir(x)

pathological documentation built on May 1, 2019, 10:22 p.m.