# Archive format and filters can be set automatically from the file extensions.
f1 <- tempfile(fileext = ".tar.gz")
write.csv(mtcars, archive_write(f1, "mtcars.csv"))
archive(f1)
unlink(f1)
# They can also be specified explicitly
f2 <- tempfile()
write.csv(mtcars, archive_write(f2, "mtcars.csv", format = "tar", filter = "bzip2"))
archive(f2)
unlink(f2)
# You can also pass additional options to control things like compression level
f3 <- tempfile(fileext = ".tar.gz")
write.csv(mtcars, archive_write(f3, "mtcars.csv", options = "compression-level=2"))
archive(f3)
unlink(f3)
Run the code above in your browser using DataLab