here_file: Find your files

Description Usage Arguments Details Project root Examples

View source: R/here.R

Description

here_file() 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.

Usage

1

Arguments

...

[character]
Path components below the project root, can be empty. Each argument should be a string containing one or more path components separated by a forward slash "/".

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.

If here_file() raises an error or otherwise behaves unexpectedly, you may have attached plyr or another package after here. Correct this using the conflicted package, or use here::here("data", "df.rda").

Project root

The project root is established with a call to here::i_am(). Although not recommended, it can be changed by calling here::i_am() again.

In the absence of such a call (e.g. for a new project), starting with the current working directory during package load time, the directory hierarchy is walked upwards until a directory with at least one of the following conditions is found:

In either case, here() appends its arguments as path components to the root directory.

Examples

1
2
3
4
5
6
here_file()
## Not run: 
here("some", "path", "below", "your", "project", "root.txt")
here("some/path/below/your/project/root.txt")

## End(Not run)

LiamABerigan/there documentation built on Dec. 18, 2020, 7:41 a.m.