This function expands system paths (the non-absolute paths become absolute) and replaces the environment variables (e.g, ${HOME}) with their values.

.expandPath(path)

Arguments

path

file path to expand. Potentially any string

Value

Expanded path or untouched string

Details

Most importantly strings that are not system paths are returned untouched

Examples

string = "https://www.r-project.org/" .expandPath(string)
#> [1] "https://www.r-project.org/"
path = "$HOME/my/path/string.txt" .expandPath(path)
#> [1] "/Users/mstolarczyk/my/path/string.txt"