write_lines: Write lines to a file

Description Usage Arguments Details Value Examples

View source: R/write_lines.R

Description

The text is converted to UTF-8 encoding before writing.

Usage

1
write_lines(text, path, eol = "\n")

Arguments

text

A character vector to write

path

A character string giving the file path to write to.

eol

The end of line characters to use between lines.

Details

The files are opened in binary mode, so they always use exactly the string given in eol as the line separator.

To write a file with windows line endings use write_lines(eol = "\r\n")

Value

The UTF-8 encoded input text (invisibly).

Examples

1
2
3
4
5
6
7
8
tf <- tempfile()

write_lines(rownames(mtcars), tf)

# Write with Windows style line endings
write_lines(rownames(mtcars), tf, eol = "\r\n")

unlink(tf)

Example output

Attaching package:brioThe following objects are masked frompackage:base:

    readLines, writeLines

brio documentation built on Dec. 11, 2021, 10:09 a.m.