| write_parquet {nanoparquet} | R Documentation |
Write a data frame to a Parquet file
Description
Writes the contents of an R data frame into a Parquet file.
Usage
write_parquet(
x,
file,
compression = c("snappy", "gzip", "zstd", "uncompressed"),
metadata = NULL,
options = parquet_options()
)
Arguments
x |
Data frame to write. |
file |
Path to the output file. If this is the string |
compression |
Compression algorithm to use. Currently |
metadata |
Additional key-value metadata to add to the file.
This must be a named character vector, or a data frame with columns
character columns called |
options |
Nanoparquet options, see |
Details
write_parquet() converts string columns to UTF-8 encoding by calling
base::enc2utf8(). It does the same for factor levels.
Value
NULL, unless file is ":raw:", in which case the Parquet
file is returned as a raw vector.
See Also
parquet_metadata(), read_parquet().
Examples
# add row names as a column, because `write_parquet()` ignores them.
mtcars2 <- cbind(name = rownames(mtcars), mtcars)
write_parquet(mtcars2, "mtcars.parquet")