This function writes a data frame to a specified file path as a tab-separated ASCII text file. It offers flexibility in formatting the output, including the choice of decimal point character, whether to include quotes, row names, and column names. The function can operate using either the base R write.table function or data.table's fwrite function for file writing.

write_ascii(
  data,
  path,
  dec = ".",
  sep = "\t",
  quote = FALSE,
  row.names = FALSE,
  col.names = TRUE,
  use_fwrite = FALSE
)

Arguments

data

A data frame that will be written to a text file.

path

The file path where the text file will be written.

dec

The character to be used as decimal point. Default is ".".

sep

The field separator character. Default is "\t" (tab).

quote

Logical; if TRUE, fields will be surrounded by quotes. Default is FALSE, meaning no quotes are used.

row.names

Logical; if TRUE, row names are written to the file. Default is FALSE, meaning row names are not included.

col.names

Logical; if TRUE, column names are written to the file. Default is TRUE, meaning column names are included.

use_fwrite

A boolean flag indicating whether to use data.table::fwrite() for file writing. Default is FALSE, which uses write.table.

Value

NULL. The function is invoked for its side effect, which is writing the data frame to a text file.