Skip to contents

These functions merge two or more fnames objects into one larger fnames object, removing duplicates (keeping only the first appearance) and only resorting the items if sort = TRUE.

Usage

fnames_merge(x, y, sort = FALSE)

fnames_merge_all(..., sort = FALSE)

Arguments

x, y

An object of class fnames.

sort

Boolean value. Should the items in the output be sorted?

...

Various objects of class fnames or a list of objects of class fnames.

Value

An object of class fnames.

Examples

cwd_fnames <- as_fnames(c("file1.txt", "file2.txt"))
cwd_fnames2 <- as_fnames(c("dir1/file3.txt", "dir1/file4.txt"))
cwd_fnames3 <- as_fnames(c("dir2/file5.txt", "dir2/file6.txt"))
fnames_merge(cwd_fnames, cwd_fnames2)
#> Filename collection of length 4
#>         filename
#>   --------------
#> 1      file1.txt
#> 2      file2.txt
#> 3 dir1/file3.txt
#> 4 dir1/file4.txt
fnames_merge_all(cwd_fnames, cwd_fnames2, cwd_fnames3)
#> Filename collection of length 6
#>         filename
#>   --------------
#> 1      file1.txt
#> 2      file2.txt
#> 3 dir1/file3.txt
#> 4 dir1/file4.txt
#> 5 dir2/file5.txt
#> 6 dir2/file6.txt