read_txt: Read a text file into a character vector

Description Usage Arguments Value See Also Examples

Description

Reads a text file and returns a character vector containing the lines in the text file (in such a way that the lines in the text file are the items in the character vector).

Usage

1
2
3
4
read_txt(file,
         file_encoding = "UTF-8",
         paste_char = NA,
         ...)

Arguments

file

name of the input file

file_encoding

the encoding used in the input file.

paste_char

if paste.char is NA, then the output is a character vector in which each input line is a separate item. If paste_char is a character vector, e.g. "\n", then the output is a character vector of length one, in which all input lines are concatenated, using the value of paste_char[1] as line separator and as end-of-last-line marker.

...

not used in the current implementation of read_txt.

Value

The function read_txt returns a character vector.

See Also

See also write_txt.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
# create a small text
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

wai-wong-reimagine/mclm documentation built on May 16, 2019, 9:12 p.m.