我试图在R中读取.csv。一列中的某些行的文本带有komma,在双引号内:"例如,另一个示例" 但是当我尝试这样读它时,R改变了行(它增加了行数):
steekproef <- read.csv('steekproef.csv', header = T, quote = "", sep = ',')
当我在互联网上搜索时,这个不起作用:
steekproef <- read.csv('steekproef.csv', header = T, quote = "\"", sep = ',')
这是错误消息:
steekproef <- read.csv("steekproef.csv", header = T, sep =",", quote ="\"")
comes with error:
Warning message:
In scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings, :
EOF within quoted string
Gives data.frame: 1391160 obs. of 29 variables
str(steekproef) gives no error but a
'data.frame': 3103620 obs. of 29 variables:
The dataset has 29 columns and 3019438 rows
答案 0 :(得分:0)
我不认为问题是由“另一个例子”引起的:
我在Excel中创建了一个测试文件并将其保存为.csv。在Notepad ++中看起来像这样:
test,num
"example, another example",1
"example, another example",2
example,3
example,4
我可以使用
毫无问题地导入它 steekproef<- read.csv('steekproef.csv', header = T, sep = ',')
或steekproef <- read.csv('steekproef.csv', header = T, quote = "\"", sep = ',')
您的第一次尝试:steekproef <- read.csv('steekproef.csv', header = T, quote = "", sep = ',')
给了我Error in read.table(file = file, header = header, sep = sep, quote = quote,: duplicate 'row.names' are not allowed