df_to_txt: df_to_txt

View source: R/df_to_txt.R

df_to_txtR Documentation

df_to_txt

Description

Save any list like data.frame, data.table or matrix to a txt-file. Uses data.table::fwrite or vroom::vroom_write depending on decimal mark. If decimal mark is ., then uses faster vroom_write. Otherwise uses fwrite.

Usage

df_to_txt(
  x,
  file = "",
  sep = "\t",
  dec = ",",
  overwrite = TRUE,
  encoding = "UTF-8",
  ...
)

Arguments

x

Any list like element e.g. data.frame and data.table.

file

Output file name. Default: to the console.

sep

Separator. Default: "tab"

dec

Decimal limiter. Default: ","

overwrite

Overwrites the file, it it exists. Default: TRUE

...

Add parameters to fwrite or vroom_write. col.names

Examples

n <- c(1.1, 2.2, 3.3)
s <- c("a", "b", "c")
x <- data.frame(n, s)
df_to_txt(x, file = "example.txt")

JouniVatanen/stools documentation built on Jan. 25, 2023, 8:49 p.m.