The functions build a subset of an object of class fnames
based on a vector
of characters, either including them (with keep_fnames(invert = FALSE)
) or
excluding them (with keep_fnames(invert = FALSE)
or drop_fnames()
).
Value
An object of class fnames
.
Examples
all_fnames <- as_fnames(c("file1", "file2", "file3",
"file4", "file5", "file6"))
unwanted_fnames <- as_fnames(c("file1", "file4"))
keep_fnames(all_fnames, unwanted_fnames, invert = TRUE)
#> Filename collection of length 4
#> filename
#> --------
#> 1 file2
#> 2 file3
#> 3 file5
#> 4 file6
drop_fnames(all_fnames, unwanted_fnames)
#> Filename collection of length 4
#> filename
#> --------
#> 1 file2
#> 2 file3
#> 3 file5
#> 4 file6
wanted_fnames <- as_fnames(c("file3", "file5"))
keep_fnames(all_fnames, wanted_fnames)
#> Filename collection of length 2
#> filename
#> --------
#> 1 file3
#> 2 file5