R 读取.csv带有逗号分隔符和字符换行符



我希望 R 阅读.csv带有逗号分隔符但分号换行符。数据没有空格或换行符。我该怎么做?

一种解决方案是将文件作为字符串读取,并将分号替换为换行符。

fileName = 'myfile.txt'
filecontent = readChar(fileName, file.info(fileName)$size)
filecontent = gsub(";", "n", filecontent)
con = textConnection(filecontent)
read.table(con,sep=",")

最新更新