writetype_delim: Write a data frame to a delimited file, and save typing...

View source: R/saving.R

writetype_delimR Documentation

Write a data frame to a delimited file, and save typing information in a separate json file

Description

Write a data frame to a delimited file, and save typing information in a separate json file

Usage

writetype_delim(
  x,
  path,
  suffix = "",
  delim = " ",
  na = "NA",
  quote_escape = "double",
  eol = "\n"
)

Arguments

x

A data frame or tibble to write to disk.

path

File or connection to write to. (path is now deprecated in readr v1.4 for OpenSAFELY currently has older version, so use path for now)

suffix

The suffix used in the name of the json file, to be appended to the delimited file name. Defaults to "" (no suffix), so that the file name is the same as the delimited file name (excluding filetype extensions).

delim

Delimiter used to separate values.

na

String used for missing values. Defaults to "NA". Missing values will never be quoted; strings with the same value as na will always be quoted.

quote_escape

The type of escaping to use for quoted values, one of "double", "backslash" or "none". You can also use FALSE, which is equivalent to "none". The default is "double", which is expected format for Excel.

eol

The end of line character to use. Most commonly either "⁠\n⁠" for Unix style newlines, or "⁠\r\n⁠" for Windows style newlines.

Details

Based on the readr::write_delim function. Additionally, this function saves a json file containing typing info for the data frame, which can be used to re-type the data when re-imported into R. Some further readr::write_delim options are deliberately unavailable as they won't make sense for files intended for re-importing. Datetime and time classes are not supported.

Value

Returns the input invisibly.


wjchulme/osutils documentation built on Dec. 20, 2024, 9:56 a.m.