readr (version 1.0.0)

write_lines: Write lines/ a file

Description

write_lines takes a character vector, appending a new line after entry. write_file takes a single string, or a raw vector, and writes it exactly as is.

Usage

write_lines(x, path, na = "NA", append = FALSE)
write_file(x, path, append = FALSE)

Arguments

x
A data frame to write to disk
path
Path to write to.
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.
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.

Value

The input x, invisibly.

Examples

Run this code
tmp <- tempfile()

write_lines(rownames(mtcars), tmp)
read_lines(tmp)
read_file(tmp) # note trailing \n

write_lines(airquality$Ozone, tmp, na = "-1")
read_lines(tmp)

Run the code above in your browser using DataCamp Workspace