here: Find your files

Description Usage Arguments Details Project root Examples

Description

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.

Usage

1
2
3
4
5
here(...)

dr_here(show_reason = TRUE)

set_here(path = ".", verbose = TRUE)

Arguments

...

[character]
Path components below the project root, can be empty.

show_reason

[logical(1)]
Include reason in output of dr_here(), defaults to TRUE.

path

[character(1)]
Directory where to create .here file, defaults to the current directory.

verbose

[logical(1)]
Verbose output, defaults to TRUE.

Details

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.

Project root

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:

Once established, the root directory doesn't change during the active R session. here() then appends the arguments to the root directory.

Examples

1
2
here()
## Not run: here("some/path/below/your/project/root.txt")

here documentation built on May 1, 2019, 11:29 p.m.