Skip to contents

This function reads a text file and returns a character vector containing the lines in the text file.

Usage

read_txt(file, file_encoding = "UTF-8", line_glue = NA, ...)

Arguments

file

Name of the input file.

file_encoding

Encoding of the input file.

line_glue

A character vector or NA. If NA, the output is a character vector in which each input line is a separate item, as in readr::read_lines(). Otherwise, the output is a character vector of length 1 in which all input lines are concatenated, using the value of line_glue[1] as line separator and as end-of-last-line marker.

...

Additional arguments (not implemented).

Value

A character vector.

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)