fnames {mclm} | R Documentation |
Retrieve the names of files in a given path
Description
Build an object of class fnames
.
Usage
get_fnames(
path = ".",
re_pattern = NULL,
recursive = TRUE,
perl = TRUE,
invert = FALSE
)
Arguments
path |
The location of the files to be listed. |
re_pattern |
Optional regular expression. If present, then only the
filenames that match it are retrieved (unless |
recursive |
Boolean value. Should the subdirectories of |
perl |
Boolean value. Whether |
invert |
Boolean value. If |
Value
An object of class fnames
, which is a special kind of character
vector storing the absolute paths of the corpus files.
It has additional attributes and methods such as:
base
print()
,as_data_frame()
,sort()
andsummary()
(which returns the number of items and of unique items),an interactive
explore()
method,a function to get the number of items
n_fnames()
,subsetting methods such as
keep_types()
,keep_pos()
, etc. including[]
subsetting (see brackets), as well as the specific functionskeep_fnames()
anddrop_fnames()
.
Additional manipulation functions includes fnames_merge()
to combine
filenames collections and the short_names()
family of functions to shorten
the names.
Objects of class fnames
can be saved to file with write_fnames()
;
these files can be read with read_fnames()
.
It is possible to coerce a character vector into an fnames
object with as_fnames()
.
Examples
cwd_fnames <- get_fnames(recursive = FALSE)
cwd_fnames <- as_fnames(c("file1", "file2", "file3"))
cwd_fnames
print(cwd_fnames)
as_data_frame(cwd_fnames)
as_tibble(cwd_fnames)
sort(cwd_fnames)
summary(cwd_fnames)