Skip to content

Writes as UTF-8 encoding and with \n line endings on UNIX systems and \r\n on Windows. This avoids some of the unintended side-effects of usethis::write_over() with R-projects.

Usage

write_text(path, lines, overwrite = FALSE)

read_text(path, n = -1L)

Arguments

path

Path to target file. It is created if it does not exist, but the parent directory must exist.

lines

Character vector of lines. For write_union(), these are lines to add to the target file, if not already present. For write_over(), these are the exact lines desired in the target file.

overwrite

logical(1). If file exists, over-write it?

n

integer. The (maximal) number of lines to read. Negative values indicate that one should read up to the end of input on the connection.

Functions

  • read_text(): a convenient wrapper to readLines() with default UTF-8 encoding for reading text into an R session.