The difference between read.table and read.delim

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

+5
r read.table
source share
2 answers

In addition to reading the manual pages, when you don’t know what the function does, you can also check the actual function code. For example, typing read.delim indicates 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, ...) 

So read.delim() is just a wrapper function for read.table() with default argument values ​​that are convenient when reading in tab-delimited data. This is exactly the same as the call:

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

From R help:

Similarly, read.delim and read.delim2 are designed to read delimited files, by default for the TAB character for the delimiter. Note that header = TRUE and fill = TRUE in these options, and the comment character is disabled.

+3
source share

All Articles