Learn R Programming

pathological (version 0.0-8)

split_path: Split a path into directory components

Description

Splits a character vector of paths into directory components. The opposite of file.path.

Usage

split_path(x = dir())

Arguments

x
A character vector of file paths. Defaults to files in the current directory.

Value

  • A named list of character vectors containing the split paths.

Examples

Run this code
(splits <- split_path(c(getwd(), "~", r_home())))
# Reverse the operation
sapply(splits, paste, collapse = "/")

Run the code above in your browser using DataLab