read.csv()和read.csv2()在R中的区别 [英] Difference between read.csv() and read.csv2() in R

查看:3987
本文介绍了read.csv()和read.csv2()在R中的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

In R , what is the difference between read.csv() and read.csv2()

官方文档说,


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

In various European locales, as the comma character serves as the decimal point, the function read.csv2 should be used instead

这是什么意思。我在表面上看不出任何区别。

What does this mean. I don't see any difference at the superficial level. Can anybody give out a concrete example to clarify it further.

推荐答案

它们(几乎)具有相同的功能 - read.table 。唯一的区别是默认参数。查看源代码:

They are (almost) the same functions - read.table. The only difference is default parameters. Look at source code:

> 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.csv read.csv2 除了默认值外,与 read.table 相同。它们用于读取逗号分隔值文件('.csv')或(read.csv2)在使用逗号作为小数点和分号作为字段分隔符的国家/地区中使用的变体。

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.

这篇关于read.csv()和read.csv2()在R中的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆