path_parent_dir: Find the parent directory for a path

View source: R/path_parent_dir.R

path_parent_dirR Documentation

Find the parent directory for a path

Description

Supply a path, get the parent folder

Usage

path_parent_dir(filepath, n_levels = 1, test_existence = FALSE)

Arguments

filepath

the file path

n_levels

how many levels do you want to go up? default=1 goes up to the parent folder level

test_existence

do you want to test whether filepath file exists?

Examples

path_to_file<-"Users/me/folder/subfolder/photo.png"
(path_to_subfolder<-path_parent_dir(path_to_file))
path_parent_dir(path_to_subfolder)

#get same result from:
path_parent_dir(path_to_file,n_levels=2)


galacticpolymath/GPpub documentation built on April 5, 2025, 6:04 p.m.