thisisnic commented on a change in pull request #91: URL: https://github.com/apache/arrow-cookbook/pull/91#discussion_r738215256
########## File path: r/content/reading_and_writing_data.Rmd ########## @@ -359,3 +358,121 @@ unlink("my_table.parquet") unlink("dist_time.parquet") unlink("airquality_partitioned", recursive = TRUE) ``` + +## Write compressed data + +You want to save a file, compressed with a specified compression algorithm. + +### Solution + +```{r, parquet_gzip} +# Create a temporary directory +td <- tempfile() +dir.create(td) + +# Write data compressed with the gzip algorithm +write_parquet(iris, file.path(td, "iris.parquet"), compression = "gzip") +``` + +```{r, test_parquet_gzip, opts.label = "test"} +test_that("parquet_gzip", { + file.exists(file.path(td, "iris.parquet")) +}) +``` + +### Discussion + +You can also supply the `compression` argument to `write_dataset()`, as long as +the compression algorithm is compatible with the chosen format. + +```{r, dataset_gzip} +# Create a temporary directory +td <- tempfile() +dir.create(td) + +# Write dataset to file +write_dataset(iris, path = td, format = "feather", compression = "gzip") Review comment: You are correct - I forgot to update this to save to Parquet. Incidentally, I also opened this ticket: https://issues.apache.org/jira/browse/ARROW-14461 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: github-unsubscr...@arrow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org