Learn R Programming

readtext (version 0.91)

basename_unique: Return basenames that are unique

Description

Return basenames that are unique

Usage

basename_unique(x, path_only = FALSE)

Arguments

x

character vector; file paths

path_only

logical; if TRUE, only return the unique part of the path

Examples

Run this code
files <- c("../data/glob/subdir1/test.txt", "../data/glob/subdir2/test.txt")
readtext:::basename_unique(files)
# [1] "subdir1/test.txt" "subdir2/test.txt"
readtext:::basename_unique(files, path_only = TRUE)
# [1] "subdir1" "subdir2"
readtext:::basename_unique(c("../data/test1.txt", "../data/test2.txt"))
# [1] "test1.txt" "test2.txt"

Run the code above in your browser using DataLab