View source: R/relative_path.R
relative_path | R Documentation |
After normalizing both file
and dir
, try to find a common
ancestor directory to build a path for file
relative to dir
.
relative_path(file, dir = getwd())
file |
A single string with the path to a file or directory to transform as relative. |
dir |
A single string with the "reference" directory (by default, the
directory provided by |
A single character string with the relative path, or file
unmodified if file
is totally unrelated to dir
.
Philippe Grosjean phgrosjean@sciviews.org
getwd()
, normalizePath()
relative_path("/Users/me/project/file.txt", "/Users/me/project")
relative_path("/Users/me/project/subdir/file.txt", "/Users/me/project")
relative_path("/Users/me/file.txt", "/Users/me/project")
relative_path("/Users/me/subdir/file.txt", "/Users/me/project")
relative_path("/Users/file.txt", "/Users/me/project")
relative_path("/Users/subdir1/subdir2/file.txt", "/Users/me/project")
relative_path("/Unrelated/file.txt", "/Users/me/project")
relative_path("file.txt", "/Users/me/project")
relative_path("~/file.txt", "/Users/me/project")
relative_path("./file.txt", "/Users/me/project")
relative_path(file.path(getwd(), "data.io", "file.txt"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.