The “filenamer” package can be useful for creating filenames in R. Commands such as “insert” to insert a string into the filename and “set_fext” to change only the extension can be useful.
As an added bonus, here is a command to specify the working folder in the GUI.
Package version is 0.2.3. Checked with R version 4.2.2.
Run the following command.
#Install Package install.packages("filenamer")
See the command and package help for details.
#Loading the library library("filenamer") #Create file name:filename command #Output in "filename" class #Designation of extensions:ext option f <- filename("TEST", ext = "csv") #"filename" class to text:tag command tag(f)  "TEST.csv" #Insert string in file name:insert command #Specification of string:tag command Finsert <- insert(f, tag = "TEST2") tag(Finsert)  "TEST_TEST2.csv" #Change file extension:set_fext command Ffext <- set_fext(f, "pdf") tag(Ffext)  "TEST.pdf" #bonus #Specify working folders via GUI library("tcltk") FoldPath <- paste(as.character(tkchooseDirectory(title = "Select Folder"), sep = "", collapse =""))
I hope this makes your analysis a little easier !!