Difference between read.table and read.delim functions

user1021713 picture user1021713 · May 15, 2012 · Viewed 33.4k times · Source

What is the difference between the read.table() and read.delim() functions in the R language?

Answer

jthetzel picture jthetzel · May 15, 2012

In addition to reading help pages when you are unsure of what a function does, you can also examine the function's actual code. For example, entering read.delim reveals that the function contains the following code:

> read.delim
function (file, header = TRUE, sep = "\t", quote = "\"", dec = ".", 
    fill = TRUE, comment.char = "", ...) 
read.table(file = file, header = header, sep = sep, quote = quote, 
    dec = dec, fill = fill, comment.char = comment.char, ...)

Thus, read.delim() is simply a wrapper function for read.table() with default argument values that are convenient when reading in tab-separated data. It is exactly the same as calling:

read.table(file, header = TRUE, sep = "\t", quote = "\"", 
    dec = ".", fill = TRUE, comment.char = "")