Learn R Programming

this.path (version 1.2.0)

check.path: Check this.path() is Functioning Correctly

Description

Add check.path("path/to/file") to the beginning of your script to initialize this.path(), and check that this.path() is returning the path you expect.

Usage

check.path(...)
check.dir(...)

Value

If the expected path / / directory matches this.path() / / this.dir(), then TRUE invisibly.

Otherwise, an error is raised.

Arguments

...

further arguments passed to path.join which must return a character string; the path you expect this.path() or this.dir() to return. The specified path can be as deep as necessary (just the basename, the last directory and the basename, the last two directories and the basename, ...), but using an absolute path is not intended (recommended against). this.path() makes R scripts portable, but using an absolute path in check.path or check.dir makes an R script non-portable, defeating the whole purpose of this package.

Examples

Run this code
# I have a project called 'EOAdjusted'
#
# Within this project, I have a folder called 'code'
# where I place all of my scripts.
#
# One of these scripts is called 'provrun.R'
#
# So, at the top of that R script, I could write:


# this.path::check.path("EOAdjusted", "code", "provrun.R")
#
# or
#
# this.path::check.path("EOAdjusted/code/provrun.R")

Run the code above in your browser using DataLab