write_data: Write common file formats

Description Usage Arguments Note Author(s) Examples

Description

A simple wrapper for writing common data formats. The format is determined by the extension given in file. Flat files are written with readr, and the encoding is always UTF-8. For xlsx, the function uses to_excel (which in turn uses openxlsx).

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
write_data(x, file, ..., delim = NULL)

## S3 method for class 'data.frame'
write_data(x, file, ..., delim = NULL)

## S3 method for class 'list'
write_data(x, file, ...)

## S3 method for class 'ggplot'
write_data(x, file, ...)

Arguments

x

The data to be written. (data.frame or list. matrix and table will be coerced to a data.frame.

file

Path and filename of output.

...

Further arguments passed to underlying functions. (Currently: save, saveWorkbook, ggsave, write_delim and write_sav.)

delim

The delimiter to use when writing flat files.

Note

Use lapply to write a list of data to flat files (csv, txt etc).

Author(s)

Kristian D. Olsen

Examples

1
2
3
4
5
## Not run: 
df <- data.frame("String" = c("A", "B"), "Int" = c(1:2L), "Percent" = c(0.5, 0.75))
write_data(df, file = "example data.csv")

## End(Not run)

itsdalmo/officeR documentation built on May 18, 2019, 7:11 a.m.