Reading a tab separated file in R

Misha picture Misha · Jul 4, 2018 · Viewed 8.4k times · Source

I'm trying to read a file in R but the fourth record appears as a new line (see attached). After the third line, there's no tab, just two spaces. I'm using this code:

df = read.delim("text.txt", header = FALSE, stringsAsFactors = FALSE, quote = "")

UPDATE: the third line has "¬" at the end.

enter image description here

Answer

Shinobi_Atobe picture Shinobi_Atobe · Jul 4, 2018

use the sep argument of read.delim to specify the separator. in this case you would need

df = read.delim("text.txt", header = FALSE, stringsAsFactors = FALSE, quote = "", sep = "\t")