common_path | R Documentation |
Find common prefix of two or more (normalised) file paths
common_path(paths, normalise = FALSE, fsep = .Platform$file.sep)
paths |
Character vector of file paths |
normalise |
Whether to normalise |
fsep |
Optional path separator (defaults to |
Note that for absolute paths, the common prefix will be returned
e.g. common_path(c("/a","/b"))
is "/"
Note that normalizePath
1) operates according to the
conventions of the current runtime platform 2) is called with
winslash=.Platform$file.sep
which means that normalised paths will
eventually end up separated by "\" by default on Windows rather than by
"//", which is normalizePath
's standard behaviour.
Character vector of common prefix, ""
when there is no common
prefix, or the original value of paths
when fewer than 2 paths were
supplied.
normalizePath
Other path_utils:
abs2rel()
,
split_path()
common_path(c("/a","/b"))
common_path(c("/a/b/","/a/b"))
common_path(c("/a/b/d","/a/b/c/d"))
common_path(c("/a/b/d","/b/c/d"))
common_path(c("a","b"))
common_path(c("","/a"))
common_path(c("~","~/"))
common_path(c("~/a/b/d","~/a/b/c/d"), normalise = FALSE)
common_path(c("~","~/"), normalise = FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.