I am trying to use Here to easy file referencing and it is working okay if I write pdf or csv files without any sys date. For example; pdf(here("output/first.pdf))
works but not if I add any of the formatting text. Appreciate if you can help me how to make below code work with Here. Thanks!
pdf(file=paste0(projPath,format(Sys.Date(),"%Y%b%d"),".pdf"),
height = 6, width = 16)
write.csv(df,file=paste(projPath,"/output/first_",format(Sys.Date(),"%Y%b%d"),".csv",sep=""), quote=F, row.names = F, na=".")
CodePudding user response:
I recommend that you use the glue
library, it makes injecting additions into strings a breeze.
See this example
library(here)
library(glue)
(mydate <- format(Sys.Date(),"%Y%b%d"))
here(glue("something_{mydate}.pdf"))