| write_data | R Documentation |
write_data() writes a data frame to any format listed by
supported_formats(). The format is inferred from the file extension
unless format is given; text formats are compressed when the file name
ends in .gz, .bz2 or .xz.
HDF5 files are written with one dataset per column inside a group
(dataset, default "data"), with attributes that record column order,
factor levels, Date/POSIXct classes, time zones and missing strings,
so that read_data() restores the original column types.
Date-times (POSIXct) keep their instant in every format. Text formats
(CSV, TSV, JSON, NDJSON) store them as ISO 8601 strings in UTC; Excel,
SPSS, Stata and SAS files, which store clock time without a time zone,
receive the UTC clock time; Parquet, Feather, fst and HDF5 store the
instant together with the time zone. Pass the original data as template
to read_data() to restore the original time zone.
write_data(
x,
path,
format = NULL,
overwrite = TRUE,
object = "data",
dataset = "data",
...
)
x |
A data frame (matrices are converted). |
path |
Output file path. |
format |
Optional format name or extension. |
overwrite |
Overwrite an existing file? |
object |
For |
dataset |
For |
... |
Further arguments passed to the backend writer. |
The path, invisibly.
read_data(), generate_to_file()
f <- tempfile(fileext = ".tsv.gz")
write_data(mtcars, f)
head(read_data(f))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.