basename removes all of the path up to and including the last path separator (if any). dirname returns the part of the path up to but excluding the last path separator, or "." if there is no path separator.
basename(path)
dirname(path)
| Parameter | Description |
|---|---|
path |
character vector, containing path names. |
# NOT RUN {
basename(file.path("","p1","p2","p3", c("file1", "file2")))
dirname(file.path("","p1","p2","p3","filename"))
# }