Skip to contents

Export

Usage

export(object, con, format, ...)

# S4 method for DataFrame,character,missing
export(
  object,
  con,
  format,
  rownames = TRUE,
  colnames = TRUE,
  overwrite = getOption(x = "acid.overwrite", default = TRUE),
  engine = getOption(x = "acid.export.engine", default = "base"),
  quiet = getOption(x = "acid.quiet", default = FALSE)
)

# S4 method for GenomicRanges,character,missing
export(
  object,
  con,
  format,
  rownames = TRUE,
  colnames = TRUE,
  overwrite = getOption(x = "acid.overwrite", default = TRUE),
  engine = getOption(x = "acid.export.engine", default = "base"),
  quiet = getOption(x = "acid.quiet", default = FALSE)
)

# S4 method for Matrix,character,missing
export(
  object,
  con,
  format,
  overwrite = getOption(x = "acid.overwrite", default = TRUE),
  quiet = getOption(x = "acid.quiet", default = FALSE)
)

# S4 method for atomic,character,missing
export(
  object,
  con,
  format,
  append = FALSE,
  overwrite = getOption(x = "acid.overwrite", default = TRUE),
  engine = getOption(x = "acid.export.engine", default = "base"),
  quiet = getOption(x = "acid.quiet", default = FALSE),
  verbose = getOption(x = "acid.verbose", default = FALSE)
)

# S4 method for data.frame,character,missing
export(
  object,
  con,
  format,
  rownames = TRUE,
  colnames = TRUE,
  overwrite = getOption(x = "acid.overwrite", default = TRUE),
  engine = getOption(x = "acid.export.engine", default = "base"),
  quiet = getOption(x = "acid.quiet", default = FALSE)
)

# S4 method for matrix,character,missing
export(
  object,
  con,
  format,
  rownames = TRUE,
  colnames = TRUE,
  overwrite = getOption(x = "acid.overwrite", default = TRUE),
  engine = getOption(x = "acid.export.engine", default = "base"),
  quiet = getOption(x = "acid.quiet", default = FALSE)
)

# S4 method for ANY,missing,missing
export(
  object,
  con,
  format,
  dir = getOption(x = "acid.export.dir", default = getwd()),
  ...
)

Arguments

object

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

con

character(1), missing, or NULL. File path. Alternatively, can leave unset and use ext and dir arguments instead.

format

character(1), missing, or NULL. Currently not supported.

rownames

logical(1). Apply to row names.

colnames

logical(1). Apply to column names.

overwrite

logical(1). Overwrite existing file on disk.

engine

character(1). Engine (package) to use for export.

Currently supported:

  • base

  • data.table

  • readr

quiet

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

append

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

verbose

logical(1). Run the function with verbose output.

dir

character(1). Directory path.

...

Additional arguments.

Value

Invisible character. File path(s).

Note

Updated 2022-09-13.

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".

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 readr::write_delim() by default for exporting DataFrame, data.frame, and matrix class objects.

Examples

counts <- matrix(data = seq_len(100L), nrow = 10)
export(object = counts, con = "counts.csv")
#> → Exporting counts.csv using base::`write.table()`.

## Clean up.
file.remove("counts.csv")
#> [1] TRUE