vroom (version 1.0.2)

vroom_write: Write a data frame to a delimited file

Description

Write a data frame to a delimited file

Usage

vroom_write(x, path, delim = "\t", na = "NA", col_names = !append,
  append = FALSE, quote = c("needed", "all", "none"),
  escape = c("double", "backslash", "none"), bom = FALSE,
  num_threads = vroom_threads(), progress = vroom_progress())

Arguments

x

A data frame to write to disk

path

Path or connection to write to.

delim

One of more characters used to delimiter fields within a record. If NULL the delimiter is guessed from the set of c(",", "\t", " ", "|", ":", ";", "\n").

na

Character vector of strings to interpret as missing values. Set this option to character() to indicate no missing values.

col_names

Either TRUE, FALSE or a character vector of column names.

If TRUE, the first row of the input will be used as the column names, and will not be included in the data frame. If FALSE, column names will be generated automatically: X1, X2, X3 etc.

If col_names is a character vector, the values will be used as the names of the columns, and the first row of the input will be read into the first row of the output data frame.

Missing (NA) column names will generate a warning, and be filled in with dummy names X1, X2 etc. Duplicate column names will generate a warning and be made unique with a numeric prefix.

append

If FALSE, will overwrite existing file. If TRUE, will append to existing file. In both cases, if file does not exist a new file is created.

quote

How to handle fields which contain characters that need to be quoted.

  • needed - Only quote fields which need them.

  • all - Quote all fields.

  • none - Never quote fields.

escape

The type of escape to use when quotes are in the data.

  • double - quotes are escaped by doubling them.

  • backslash - quotes are escaped by a preceding backslash.

  • none - quotes are not escaped.

bom

If TRUE add a UTF-8 BOM at the beginning of the file. This is recommended when saving data for consumption by excel, as it will force excel to read the data with the correct encoding (UTF-8)

num_threads

Number of threads to use when reading and materializing vectors.

progress

Display a progress bar? By default it will only display in an interactive session and not while knitting a document. The display is updated every 50,000 values and will only display if estimated reading time is 5 seconds or more. The automatic progress bar can be disabled by setting option readr.show_progress to FALSE.

Examples

Run this code
# NOT RUN {
# If you only specify a file name, vroom_write() will write
# the file to your current working directory.
out_file <- tempfile(fileext = "csv")
vroom_write(mtcars, out_file, ",")

# You can also use a literal filename
# vroom_write(mtcars, "mtcars.tsv")

# If you add an extension to the file name, write_()* will
# automatically compress the output.
# vroom_write(mtcars, "mtcars.tsv.gz")
# vroom_write(mtcars, "mtcars.tsv.bz2")
# vroom_write(mtcars, "mtcars.tsv.xz")
# }

Run the code above in your browser using DataCamp Workspace