天天看點

R語言檔案讀取方法|read.table()和read.csv()、read.delim()的差別

除了預設分隔符不同,沒有其它差別!

請看官方文檔:

read.csv and read.csv2 are identical to read.table except for the

defaults. They are intended for reading ‘comma separated value’ files

(‘.csv’) or (read.csv2) the variant used in countries that use a comma

as decimal point and a semicolon as field separator. Similarly,

read.delim and read.delim2 are for reading delimited files, defaulting

to the TAB character for the delimiter. Notice that header = TRUE and

fill = TRUE in these variants, and that the comment character is

disabled.

翻譯:

read.csv和read.csv2與read.table相同,但預設值除外。

它們用于讀取“逗号分隔值”檔案(’.csv’)或(read.csv2)在使用逗号作為小數點和分号作為字段分隔符的國家/地區中使用的變體。

類似地,read.delim和read.delim2用于讀取預設分隔符為TAB的檔案。 請注意,這些變體中的header =

TRUE和fill = TRUE,并且注釋字元已禁用。

《R語言實戰》:

讀取Excel檔案,推薦先導出成.csv檔案再用read.csv導入。如果要直接導入,可以用xlsx包。

注:對于大型資料的讀取可以使用readr包和readxl包,速度比read.table()快很多。