Learn R Programming

xfun (version 0.48)

is_sub_path: Test if a path is a subpath of a dir

Description

Check if the path starts with the dir path.

Usage

is_sub_path(x, dir, n = nchar(dir))

Value

A logical vector.

Arguments

x

A vector of paths.

dir

A vector of directory paths.

n

The length of dir paths.

Examples

Run this code
xfun::is_sub_path("a/b/c.txt", "a/b")  # TRUE
xfun::is_sub_path("a/b/c.txt", "d/b")  # FALSE
xfun::is_sub_path("a/b/c.txt", "a\\b")  # FALSE (even on Windows)

Run the code above in your browser using DataLab