Skip to contents

Given an absolute path, it returns the relative path with respect to a base (by default, the working directory in R)

Usage

path_relative(path, base = getwd())

Arguments

path

the full path

base

optional, the base with respect to which the relative path is built. It defaults to the current working directory in R.

Value

a character string with the relative path ("." if path is base)

Details

The relative path is built by fs::path_rel(), which compares whole directory names, so that e.g. /home/user/abd/file relative to /home/user/abc is ../abd/file.