here()
uses a reasonable heuristics to find your project's files, based on
the current working directory at the time when the package is loaded.
Use it as a drop-in replacement for file.path()
, it will always locate the
files relative to your project root.
dr_here()
shows a message that by default also includes the
reason why here()
is set to a particular directory. Use this function
if here()
gives unexpected results.
set_here()
creates an empty file named .here
, by default
in the current directory. When here
encounters such a file, it uses the
directory that contains this file as root. This is useful if none of the
default criteria apply.
here(...)dr_here(show_reason = TRUE)
set_here(path = ".", verbose = TRUE)
[character]
Path components below the project root, can be empty.
[logical(1)]
Include reason in output of dr_here()
, defaults to TRUE
.
[character(1)]
Directory where to create .here
file, defaults to the current directory.
[logical(1)]
Verbose output, defaults to TRUE
.
Starting with the current working directory during package load time, here
will walk the directory hierarchy upwards until it finds a directory that satisfies at least one of the following conditions:
contains a file .here
contains a file matching [.]Rproj$
with contents matching ^Version:
in the first line
contains a file DESCRIPTION
with contents matching ^Package:
contains a file remake.yml
contains a file .projectile
contains a directory .git
contains a directory .svn
Once established, the root directory doesn't change during the active R session. here()
then appends the arguments to the root directory.
This package is intended for interactive use only.
Use rprojroot::has_file()
or the other functions in
the rprojroot package for more control,
or for package development.
# NOT RUN {
here()
# }
# NOT RUN {
here("some/path/below/your/project/root.txt")
# }
Run the code above in your browser using DataLab