gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-02 02:27:16 25 4
gpt4 key购买 nike

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

官方文档说,

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

这是什么意思。从表面上看,我没有看到任何区别。任何人都可以给出一个具体的例子来进一步澄清它。

最佳答案

它们(几乎)是相同的函数 - 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>

来自文档(参见?read.table):

除了默认值外,

read.csvread.csv2read.table 相同。它们用于读取“逗号分隔值”文件(“.csv”)或(read.csv2),这是在使用逗号作为小数点和分号作为字段分隔符的国家/地区使用的变体。

关于r - R 中 read.csv() 和 read.csv2() 之间的区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22970091/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com