LR.prj_path: Discover standard LR project directory hierarchy.

Description Usage Arguments Value Examples

View source: R/prj.R

Description

Discover standard LR project directory hierarchy. prj_root marker file (.PRJ_ROOT by default) must exist in the project root directory.

Usage

1
LR.prj_path(prj_root = NULL, marker = ".PRJ_ROOT")

Arguments

prj_root

Project Root directory if string. if NULL or FALSE – auto-discover from current working directory getwd(). if TRUE – (only use in scripts, never directly in console!) auto-discover from the path of the script being executed or sourced, otherwise getwd().

marker

Project root marker file. Must exist in the project root directory.

Value

List of essential project subdirs as functions that when called with a filename produce the correspinding path; when called without a filename return the path to the subdir itself; see Examples for details.

root

- project root

ana

- Data Analysis (src/ana)

dat

- Data directory (dat)

dat_raw

- Raw data directory (dat/raw)

doc

- Documentation directory (doc)

lib

- Local Library (lib)

lib_R

- Local R Library (lib/R)

mng

- Data Munging/Wrangling (src/mng)

rpt

- Reports (doc/rpt)

src

- Source tree (src)

src_lib

- Common code under Source tree (src/lib)

pkg

- In case some code is made into R-packages (pkg)

Examples

1
2
3
4
5
6
7
8
9
## Not run: 
if(!exists('prj')){ prj <- LRutil::LR.prj_path() }
prj$root()  # return prj_root
prj$root('readme') # returns path to prj_root/readme
prj$dat_raw('foo.csv') #returns path to prj_root/dat/raw/foo.csv
prj$src('subdir','test','t.R') #returns path to prj_root/src/subdir/test/t.R
prj$src(c('a.R','b.R')) #returns vector c('prj_root/src/a.R','prj_root/src/b.R')

## End(Not run)

slonik-az/LRutil documentation built on May 7, 2019, 3:17 p.m.