[英]include csv dataset with commas as separator in R package
I am bundling a csv dataset with my R package. 我将C数据集与R包捆绑在一起。 The dataset,
dummy.csv
, is placed into /data
folder of the package. 数据集
dummy.csv
放置在包的/data
文件夹中。
If the dataset contains semicolon ;
如果数据集包含分号
;
as field separator, all works fine. 作为字段分隔符,一切正常。 When the package is loaded, and the name of the dataset is typed to the console, fields are correctly recognized.
装入程序包并将数据集的名称键入控制台后,可以正确识别字段。 If the same dataset is stored with comma
,
as a field separator, it is not recognized - all fields are read as one string. 如果相同的数据集存储用逗号
,
作为一个字段分隔符,它无法识别-所有字段读为一个字符串。
I am on Ubuntu Linux. 我在Ubuntu Linux上。
As per RFC 4180 fields in CSV are to be separated by commas. 根据RFC 4180,CSV中的字段将用逗号分隔。 How do I include a comma separated file to R package?
如何将逗号分隔的文件包含到R包中?
假设您使用read.csv
,请在命令中定义分隔符( sep =
): read.csv(file, header = TRUE, sep = ",", quote = "\\"", dec = ".", fill = TRUE, comment.char = "", ...)
。使用?read.csv
获得更多相关信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.