export: Export

Description Usage Arguments Value Row names Debugging Note See Also Examples

Description

Export data out of R and write to disk.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
export(object, ...)

## S4 method for signature 'character'
export(
  object,
  ext = c("txt", "txt.bz2", "txt.gz", "txt.xz", "txt.zip"),
  dir = getOption("acid.export.dir", default = "."),
  file = NULL,
  append = FALSE,
  overwrite = getOption("acid.overwrite", default = TRUE),
  engine = getOption(x = "acid.export.engine", default = "base"),
  quiet = getOption("acid.quiet", default = FALSE)
)

## S4 method for signature 'matrix'
export(
  object,
  ext = getOption("acid.export.ext", default = "csv"),
  dir = getOption("acid.export.dir", default = "."),
  file = NULL,
  rownames = TRUE,
  colnames = TRUE,
  overwrite = getOption("acid.overwrite", default = TRUE),
  engine = getOption(x = "acid.export.engine", "data.table"),
  quiet = getOption("acid.quiet", default = FALSE)
)

## S4 method for signature 'data.frame'
export(
  object,
  ext = getOption("acid.export.ext", default = "csv"),
  dir = getOption("acid.export.dir", default = "."),
  file = NULL,
  rownames = TRUE,
  colnames = TRUE,
  overwrite = getOption("acid.overwrite", default = TRUE),
  engine = getOption(x = "acid.export.engine", "data.table"),
  quiet = getOption("acid.quiet", default = FALSE)
)

## S4 method for signature 'DataFrame'
export(
  object,
  ext = getOption("acid.export.ext", default = "csv"),
  dir = getOption("acid.export.dir", default = "."),
  file = NULL,
  rownames = TRUE,
  colnames = TRUE,
  overwrite = getOption("acid.overwrite", default = TRUE),
  engine = getOption(x = "acid.export.engine", "data.table"),
  quiet = getOption("acid.quiet", default = FALSE)
)

## S4 method for signature 'Matrix'
export(
  object,
  ext = c("mtx.gz", "mtx.bz2", "mtx.xz", "mtx.zip", "mtx"),
  dir = getOption("acid.export.dir", default = "."),
  file = NULL,
  overwrite = getOption("acid.overwrite", default = TRUE),
  quiet = getOption("acid.quiet", default = FALSE)
)

## S4 method for signature 'GenomicRanges'
export(
  object,
  ext = getOption("acid.export.ext", default = "csv"),
  dir = getOption("acid.export.dir", default = "."),
  file = NULL,
  rownames = TRUE,
  colnames = TRUE,
  overwrite = getOption("acid.overwrite", default = TRUE),
  engine = getOption(x = "acid.export.engine", "data.table"),
  quiet = getOption("acid.quiet", default = FALSE)
)

Arguments

object

Object. An object supporting dim(), or a supported class capable of being coerced to data.frame, to be written to disk.

ext

character(1). Output file format extension.

matrix supported arguments:

  • Comma separated values (CSV): "csv", "csv.bz2", "csv.gz", "csv.xz", "csv.zip".

  • Tab separated values (TSV): "tsv", "tsv.bz2", "tsv.gz", "tsv.xz", "tsv.zip".

Matrix (sparseMatrix) supported arguments:

  • MatrixMarket exchange (MTX): "mtx", "mtx.bz2", "mtx.gz", "mtx.xz", "mtx.zip".

dir

character(1). Directory path.

file

character(1). File path. When left unset (default), the ext and dir arguments will be used instead.

append

logical(1). Append to output file. When enabled, automatically sets overwrite argument to FALSE. Requires readr package to be installed.

overwrite

logical(1). Overwrite existing file on disk.

engine

character(1). Engine (package) to use for export. Currently supported:

  • base

  • data.table

  • readr

  • vroom

quiet

logical(1). Perform command quietly, suppressing messages.

rownames

logical(1). Apply to row names.

colnames

logical(1). Apply to column names.

...

Additional arguments.

Value

Invisible character. File path(s).

Row names

Some export utilities in R have a tendency to drop row names when writing to disk in CSV format. For example, the readr family of functions never write row names by design. This is a really poor default setting for handling genomic data, which often contain gene identifiers in the row names. Here we're performing any internal tibble coercion step to ensure row names are always moved to a "rowname" column in the CSV export.

Debugging

Note that this function currently wraps data.table::fwrite() by default for exporting data.frame and matrix class objects.

Note

Updated 2021-06-10.

See Also

Packages:

Export functions:

Examples

1
2
3
4
5
counts <- matrix(data = seq_len(100L), nrow = 10)
export(counts, ext = "csv")

## Clean up.
file.remove("counts.csv")

acidgenomics/pipette documentation built on Sept. 27, 2021, 9:10 a.m.