path: Construct generic paths

Description Usage Arguments Details Paths Atoms Examples

View source: R/path.R

Description

Construct generic paths pointing to some locations in the OS file system.

Usage

1
path(..., sep = .Platform$file.sep)

Arguments

...

arbitrary character vectors of same length.

sep

a character. The seperator to use when constructing paths.

Details

Vector recycling is disabled by default. Passing vectors of different lengths to ... will result in an error. Since the underlying implementation is based on base::file.path(), it should be fast and efficient.

Paths

A path specifies a unique location in a file system and acts as a Uniform Resource Locator (URL) of a file or a directory. It is the general form of the name of that resource.

Atoms

A path is constructed by using an arbitrary number of atoms, individual components of a path. In dfp, atoms are considered to be the building blocks of a path. They are usually taken from a directory tree hierarchy. Atoms are glued together by using a common seperator.

As an example, consider the following path (with a slash as the separator).

1
C:/home/user/docs/letters/letter.txt

In that path, the atoms are C:, home, user, docs, letters and letter.txt. Together, they define the unique location of the letter.txt file in the file system.

Examples

1
2
3
4
5
6
path(c("C:", "D:"), c("home", "apps"), c("user", "bin"), c("docs", "abc.txt"))
path(list("C:", "D:"), list("user", "bin"), list("docs", "letter.txt"))

## Encoding of output should be "UTF-8" (if it contain "special" characters).
fpath <- path("this", "is", "a", "test.r")
Encoding(fpath)

jeanmathieupotvin/dfp documentation built on Jan. 8, 2020, 2:32 a.m.