parent_dir
From pathological v0.1-1
by Richard Cotton
Get the parent dir
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.
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
(x <- c(
sys_which("R"),
r_home(),
r_profile_site(),
"c:/", # different behaviour under Windows/Unix
"~",
"/",
"foo/bar/nonexistent",
NA
))
parent_dir(x)
Community examples
Looks like there are no examples yet.