Learn R Programming

this.path (version 0.5.1)

here: Construct Path to File, Beginning with this.dir()

Description

Construct the path to a file from components in a platform-independent way, starting with this.dir().

Usage

here(..., .. = 0)
ici(..., .. = 0)

Arguments

further arguments passed to file.path().

..

the number of directories to go back.

Value

A character vector of the arguments concatenated term-by-term, beginning with the executing script's directory.

Details

The path to a file begins with a base. The base is .. number of directories back from the executing script's directory (this.dir()). The argument is named .. because ".." refers to the parent directory in Windows, Unix, and URL paths alike.

Examples

Run this code
# NOT RUN {
this.path:::write.code(file = FILE <- tempfile(), {


    this.path::here()
    this.path::here(.. = 1)
    this.path::here(.. = 2)


    # use 'here' to read input from a file located nearby
    this.path::here(.. = 1, "input", "file1.csv")


    # or maybe to run another script
    this.path::here("script2.R")


})


source(FILE, echo = TRUE, verbose = FALSE)
# }

Run the code above in your browser using DataLab