check.path.RdAdd check.path("path/to/file") to the start of your script to
initialize this.path() and check that it is returning the
expected path.
check.path(...)
check.dir(...)
check.proj(...)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 do not use an absolute path.
this.path() makes R scripts portable, but using an absolute path in
check.path() or check.dir() makes an R script non-portable,
defeating a major purpose of this package.
check.proj() is a specialized version of check.path() that
checks the path up to the project root.
if the expected path / / directory matches this.path() / /
this.dir(), then TRUE invisibly, otherwise an error is thrown.
# ## I have a project called 'd_cead'
# ##
# ## 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:
#
#
# @R_PACKAGE_NAME@::check.path("d_cead", "code", "provrun.R")
#
# ## or:
#
# @R_PACKAGE_NAME@::check.path("d_cead/code/provrun.R")