Export data out of R and write to disk.

export(object, ...)

# S4 method for character
export(
  object,
  ext = "txt",
  dir = getOption("acid.export.dir", default = "."),
  file = NULL,
  overwrite = getOption("acid.overwrite", default = TRUE),
  quiet = getOption("acid.quiet", default = FALSE)
)

# S4 method for matrix
export(
  object,
  ext = getOption("acid.export.ext", default = "csv"),
  dir = getOption("acid.export.dir", default = "."),
  file = NULL,
  overwrite = getOption("acid.overwrite", default = TRUE),
  quiet = getOption("acid.quiet", default = FALSE)
)

# S4 method for data.frame
export(
  object,
  ext = getOption("acid.export.ext", default = "csv"),
  dir = getOption("acid.export.dir", default = "."),
  file = NULL,
  overwrite = getOption("acid.overwrite", default = TRUE),
  quiet = getOption("acid.quiet", default = FALSE)
)

# S4 method for DataFrame
export(
  object,
  ext = getOption("acid.export.ext", default = "csv"),
  dir = getOption("acid.export.dir", default = "."),
  file = NULL,
  overwrite = getOption("acid.overwrite", default = TRUE),
  quiet = getOption("acid.quiet", default = FALSE)
)

# S4 method for sparseMatrix
export(
  object,
  ext = "mtx",
  dir = getOption("acid.export.dir", default = "."),
  file = NULL,
  overwrite = getOption("acid.overwrite", default = TRUE),
  quiet = getOption("acid.quiet", default = FALSE)
)

# S4 method for GenomicRanges
export(
  object,
  ext = getOption("acid.export.ext", default = "csv"),
  dir = getOption("acid.export.dir", default = "."),
  file = NULL,
  overwrite = getOption("acid.overwrite", default = TRUE),
  quiet = getOption("acid.quiet", default = FALSE)
)

# S4 method for SummarizedExperiment
export(
  object,
  name = NULL,
  dir = getOption("acid.export.dir", default = "."),
  compress = getOption("acid.export.compress", default = FALSE),
  overwrite = getOption("acid.overwrite", default = TRUE),
  quiet = getOption("acid.quiet", default = FALSE)
)

# S4 method for SingleCellExperiment
export(
  object,
  name = NULL,
  dir = getOption("acid.export.dir", default = "."),
  compress = getOption("acid.export.compress", default = FALSE),
  overwrite = getOption("acid.overwrite", default = TRUE),
  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.

overwrite

logical(1). Overwrite existing file on disk.

quiet

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

name

character(1). Name to use on disk. If NULL, will use the name of the object instead.

compress

logical(1). Apply gzip compression to all files.

...

Additional arguments.

Value

Invisible character. File path(s).

Note

Updated 2020-06-11.

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 vroom::voom_write() by default for exporting data.frame and matrix class objects.

See also

Examples

counts <- matrix(data = seq_len(100L), nrow = 10) export(counts, ext = "csv")
#> → Exporting counts.csv using vroom::`vroom_write()`.
## Clean up. file.remove("counts.csv")
#> [1] TRUE