Question
compress files in R without structure of directories
I want to compress some files in R
using tar()
. My code is quite simple:
f <- "C:/TEMP/tarfile.tar.gz"
files_to_compress <- dir(path=tempdir(), full.names = TRUE)
tar(tarfile = f, files = files_to_compress, compression = "gzip")
The compression works, I get the file tarfile.tar.gz but in the compressed file I get the structure of tempdir(), too.
The file tarfile.tar.gz contains for instance (-> indicating a new folder layer):
C: -> Users -> MyUserName -> AppData -> Local -> Temp -> RTmpM5Dxmp -> files_to_compress
How can I compress files_to_compress
without archiving the structure of the directories, too?