Write a change table to a file, in whatever format the name implies
Source:R/yoy_write.R
yoy_write.RdWrite a change table to a file, in whatever format the name implies
Arguments
- x
An
rmbl_yoyobject fromyoy().- file
Output path.
- format
Output format.
"auto"reads it from the file extension:.html/.htm,.pdf,.csv,.tsv/.tab,.json,.md/.markdown.- ...
Passed to the format's own writer, so the colour, digit and layout options of
yoy_html()andyoy_pdf()are available here too.
Examples
d <- data.frame(year = 2019:2023, n = c(402, 377, 190, 268, 331))
y <- yoy(d, value = "n", period = "year")
for (ext in c("csv", "tsv", "json", "md", "html")) {
f <- file.path(tempdir(), paste0("change.", ext))
yoy_write(y, f)
cat(ext, file.size(f), "bytes\n")
unlink(f)
}
#> csv 519 bytes
#> tsv 519 bytes
#> json 1553 bytes
#> md 712 bytes
#> html 4872 bytes