Suppose I have a messy text file like the following for example
Today is a good
day, but I feel very tired. It seems like it is
going to rain pretty soon.
char_vector <- readLines(filename)
txt <- "Today is a good
day, but I feel very tired. It seems like it is
going to rain pretty soon."
readLines(textConnection(txt) )
# ---- teh screen output of three distinct character elements
[1] "Today is a good"
[2] "day, but I feel very tired. It seems like it is"
[3] "going to rain pretty soon."
char_vector <- readLines(textConnection(txt))
char_vector[1]
#[1] "Today is a good"
scan can do this.
scan( file="myfile.txt", what=character() )
You can use readLines
function.