Checks the specified filepath for formatting consistencies: 1) use slash instead of backslash; 2) do tilde etc. expansion; 3) remove trailing slash.
normPath(path) # S4 method for character normPath(path) # S4 method for list normPath(path) # S4 method for `NULL` normPath(path) # S4 method for missing normPath()
| path | A character vector of filepaths. |
|---|
Character vector of cleaned up filepaths.
## normalize file paths paths <- list("./aaa/zzz", "./aaa/zzz/", ".//aaa//zzz", ".//aaa//zzz/", ".\\aaa\\zzz", ".\\aaa\\zzz\\", file.path(".", "aaa", "zzz")) checked <- normPath(paths) length(unique(checked)) ## 1; all of the above are equivalent#> [1] 1## check to see if a path exists tmpdir <- file.path(tempdir(), "example_checkPath") dir.exists(tmpdir) ## FALSE#> [1] FALSE#> [1] FALSE#> [1] "/tmp/RtmpzknuyG/example_checkPath"dir.exists(tmpdir) ## TRUE#> [1] TRUEunlink(tmpdir, recursive = TRUE)