Skip to content
Back to formatted view

Raw Message

Message-ID: <7871ad69-3aec-1830-86e9-57f422758a90@yeah.net>
Date: 2016-12-23T03:24:33Z
From: Jinsong Zhao
Subject: different between read.table and read.delim

Hi there,

I have a data set file, called "ecotox.rep", which is a delimited file 
separated with "|".

When I tried to read the file with the following command,

 > df <- read.table("ecotox.rep", sep = "|", header = TRUE, 
stringsAsFactors=FALSE)

I got the error messages:

Error in scan(file = file, what = what, sep = sep, quote = quote, dec = 
dec,  :
   line 113 did not have 87 elements

However, when I read the file with the following command,

 > df <- read.delim("ecotox.rep", sep = "|", header = TRUE, 
stringsAsFactors=FALSE)

I got a correct output.

If I understand correctly, read.delim() is just wrapped from 
read.table(), why read.delim() works, but read.table() doesn't.

Thanks in advance.

Best,
Jinsong