Skip to contents

Checks and creates a directory recursively automatically.

Usage

initDir(dir)

Arguments

dir

character(1). Directory path.

Value

character(1). Directory path.

Details

Useful for setting up functions that require writes to a user-specified directory.

Note

Updated 2022-06-02.

Examples

dir <- file.path(tempdir(), "testdir")
dir.exists(dir)
#> [1] FALSE
dir <- initDir(dir)
dir.exists(dir)
#> [1] TRUE
print(dir)
#> [1] "/private/var/folders/l1/8y8sjzmn15v49jgrqglghcfr0000gn/T/RtmpUJIkTv/testdir"
unlink2(dir)