Learn R Programming

pathological (version 0.1-1)

parent_dir: Get the parent dir

Description

Gets the parent directory of the input.

Usage

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.

Examples

Run this code
(x <- c(
  sys_which("R"),
  r_home(),
  r_profile_site(),
  "c:/",  # different behaviour under Windows/Unix
  "~",
  "/",
  "foo/bar/nonexistent",
  NA
))
parent_dir(x)

Run the code above in your browser using DataLab