Remove the Common Root Parts
remove_common_root(x, n_keep = 1L, dbg = TRUE)
x | list of vectors of character as returned by
|
---|---|
n_keep | minimum number of segments to be kept in any case in the
returned relative paths. For example, two paths "a" and "a/b" have the
common root "a". Removing this root would result in relative paths
"" and "b". As this is not useful, |
dbg | if |
# Split paths at the slashes absparts <- strsplit(c("a/b/c", "a/b/d", "a/b/e/f/g", "a/b/hi"), "/") # Remove the common parts of the paths relparts <- remove_common_root(absparts)#> Removing the first 2 path segments ... ok. (0.00s)relparts#> [[1]] #> [1] "c" #> #> [[2]] #> [1] "d" #> #> [[3]] #> [1] "e" "f" "g" #> #> [[4]] #> [1] "hi" #> #> attr(,"root") #> [1] "a/b"#> [1] "a/b"