Function to concatenate paths?

Yes, file.path()

R> file.path("usr", "local", "lib")
[1] "usr/local/lib"
R> 

There is also the equally useful system.path() for files in a package:

R> system.file("extdata", "date_time_zonespec.csv", package="RcppBDT")
[1] "/usr/local/lib/R/site-library/RcppBDT/extdata/date_time_zonespec.csv"
R> 

which will get the file extdata/date_time_zonespec.csv irrespective of

  1. where the package is installed, and
  2. the OS

which is very handy. Lastly, there is also

R> .Platform$file.sep
[1] "https://stackoverflow.com/"
R> 

if you insist on doing it manually.

Leave a Comment

error code: 521