exportFile: Export data.frame or matrix objects

Description Usage Arguments Examples

View source: R/exportFile.R

Description

Export a data.frame or matrix into several common formats, and automatically prefixes a date/time field. Also optionally renames exported files to prevent replacing files with the same name.

Usage

1
2
3
4
5
6
7
8
exportFile(
  object,
  filename = "table",
  prefix = c("date", "time", "none"),
  file_format = c("tsv", "csv", "xlsx"),
  dir = "output/",
  replace = F
)

Arguments

object

a single 'data.frame' or 'matrix' object that is to be exported.

filename

a character vector of the intended file name of the object to be exported. Defaults to "table".

prefix

a character vector containing one of 'date', 'time', or NULL. 'date' prefixes date (e.g. 2021-09-25), whereas 'time' prefixes both time and date. NULL will remove the prefix altogether.

file_format

a character vector containing one or more of "tsv", "csv", and "xlsx". This species the format(s) of the exported file(s).

dir

a character vector which specifies the location of the exported files relative to the working directory

replace

a logical value specifying whether the function should check for redundant file names. If replace is set to FALSE, a new filename will be iteratively generated with a numeric suffix until a unique file name is reached.

Examples

1
2
3
4
5
6
7
8
9
## Not run: 
exportFile(x,
           filename = "data.frame",
           prefix = "time",
           file_format = c("tsv", "xlsx"),
           dir = "tables",
           replace = T)

## End(Not run)

wayneliuq/wmisc documentation built on Dec. 23, 2021, 5:08 p.m.