get_file_or_dir: Check if a path is a directory or a file

get_file_or_dirR Documentation

Check if a path is a directory or a file

Description

Checks if a provided path is a directory or a file. This allows a user to pass either a directory of files matching a provided pattern or a single file matching a provided pattern.

Usage

get_file_or_dir(
  path,
  pattern = "^(acs_nsqip_puf|puf_tar_[a-z]{1,4})(?:\\d{2})?(?:.*)?\\.txt$"
)

Arguments

path

a character vector of full path names; the default corresponds to the working directory, getwd(). Tilde expansion (see path.expand) is performed. Missing values will be ignored. Elements with a marked encoding will be converted to the native encoding (and if that fails, considered non-existent).

pattern

an optional regular expression. Only file names which match the regular expression will be returned.

Value

either a list of file paths or a single file path.


dylanrussellmd/nsqipr documentation built on Oct. 13, 2023, 11:01 a.m.