file.path: Construct Path to File

Description Usage Arguments Details Value Note


Construct the path to a file from components in a platform-independent way.


file.path(..., fsep = .Platform$file.sep)



character vectors.


the path separator to use.


The implementation is designed to be fast (faster than paste) as this function is used extensively in R itself.

It can also be used for environment paths such as PATH and R_LIBS with fsep = .Platform$path.sep.

Trailing path separators are invalid for Windows file paths apart from ‘/’ and ‘d:/’ (although some functions/utilities do accept them), so as from R 3.1.0 a trailing / or \ is removed.


A character vector of the arguments concatenated term-by-term and separated by fsep if all arguments have positive length; otherwise, an empty character vector (unlike paste).


The components are by default separated by / (not \) on Windows.

Questions? Problems? Suggestions? or email at

Please suggest features or report bugs with the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.