Skip to contents

This function writes a character vector to a text file. By default, each item in the character vector becomes a line in the text file.

Usage

write_txt(x, file = "", line_glue = "\n")

Arguments

x

A character vector.

file

Name of the output file.

line_glue

Character string to be used as end-of-line marker on disk or NA for no end-of-line marker (so that x becomes a single line).

Value

Invisibly, x.

See also

Examples

.old_wd <- setwd(tempdir())
x <- "This is
a small
text."

# write the text to a text file
write_txt(x, "example-text-file.txt")
# read a text from file
y <- read_txt("example-text-file.txt")
y
#> [1] "This is" "a small" "text."  
setwd(.old_wd)