Hi RStudio Community,
I often like to datestamp my outputs by prefixing the filename with YYYY-MM-DD_
. Currently, I use the wonderful here
package combined with base r paste0()
which feels bulky. I've also looked into datestamps with the fs
package, but haven't found any solutions there. It would be great to have an optional prefix = Sys.Date()
argument when building filepaths with here
, but this may be beyond the package scope.
I'm wondering whether others have come across this and have other workarounds you like and would recommend.
Reprex below.
Thanks for your thoughts!
Best,
Maia
library(here)
#> here() starts at /myfolder
# No datestamp
here("myfile.txt")
#> [1] "/myfolder/myfile.txt"
# Datestamp but with "/" separator
here(Sys.Date(), "myfile.txt")
#> [1] "/myfolder/2020-07-20/myfile.txt"
# Datestamp but with "_" separator
here(paste0(Sys.Date(), "_myfile.txt"))
#> [1] "/myfolder/2020-07-20_myfile.txt"
Created on 2020-07-20 by the reprex package (v0.3.0)