write.table: Alternative for write.table

Description Usage Arguments Examples

Description

Bugfix for the standard utils::write.table-function, copied from the standard-function and adapted. When using nested data.frames and quote=TRUE, the original function first looks at which "columns" are character of factor, and marks these for quoting, then flattens the structure to a matrix. This functions also inspects columns that are data.frames or comparable. See the example for the difference.

Usage

1
2
3
4
write.table(x, file = "", append = FALSE, quote = TRUE, sep = " ",
  eol = "\n", na = "NA", dec = ".", row.names = TRUE,
  col.names = TRUE, qmethod = c("escape", "double"),
  fileEncoding = "")

Arguments

x, file, append, quote, sep, eol, na, dec

See write.table

row.names, col.names, qmethod, fileEncoding

See write.table

Examples

1
2
3
4
5
6
7
8
df <- data.frame(a='One;Two;Three',
                 b=I(data.frame(c="OtherVal",
                 d='Four;Five;Six',
                 e=4)))

write.table(df, "~/../Desktop/Tempfile.csv", quote = TRUE, col.names = NA,
            sep = ";", dec = ",", qmethod = "double")
# This fails for utils::write.table, because Four;Five;Six is unquoted, rendering the csv useless

EmilBode/EmilMisc documentation built on Feb. 24, 2020, 4:11 p.m.