Read text file but ignore new lines (War and Peace)

I want to do sentiment analysis. I have tried read.csv, read.table, etc but I cannot get rid of \n or some kind of hard carriage return at the end of each line. I would like to have each observation be one sentence, so sep = “.” The text is War and Peace from the Gutenberg Project (https://www.gutenberg.org/files/2600/2600-0.txt). I copy the text from the website, save it to a text file, and then I try to read it in RStudio. Any better ideas? Thanks!

Hi @Tolstoy,
Welcome to the RStudio Community Forum.

I suggest a bit of reading:
https://www.tidytextmining.com/

There is also an R package called gutenbergr for accessing Project Gutenberg eBooks:

HTH

1 Like

This is awesome, thank you very much!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.