R中的read.csv()和read.csv2()之间的区别

在R中,read.csv()和read.csv2()有什么区别

官方文件说,

在各种欧洲语言环境中,由于逗号字符用作小数点,因此应该使用read.csv2函数

这是什么意思。 我没有看到任何表面上的差异。 谁能给出一个具体的例子来进一步澄清呢?

他们(几乎)是相同的function – read.table 。 唯一的区别是默认参数。 看源代码:

 > read.csv function (file, header = TRUE, sep = ",", quote = "\"", dec = ".", fill = TRUE, comment.char = "", ...) read.table(file = file, header = header, sep = sep, quote = quote, dec = dec, fill = fill, comment.char = comment.char, ...) <bytecode: 0x5e3fa88> <environment: namespace:utils> > read.csv2 function (file, header = TRUE, sep = ";", quote = "\"", dec = ",", fill = TRUE, comment.char = "", ...) read.table(file = file, header = header, sep = sep, quote = quote, dec = dec, fill = fill, comment.char = comment.char, ...) <bytecode: 0x5c0a330> <environment: namespace:utils> 

从doc(请参阅?read.table ):

除了缺省值之外, read.csvread.csv2read.table完全相同。 它们用于读取“逗号分隔值”文件('.csv')或(read.csv2),该国家使用逗号作为小数点和分号作为字段分隔符。