我正在尝试将以下文字读入R:
"Complete","2014 H2","123456","Local","789123","File of files","A","142","000","Text",""Sharp Yield Rise
-3.7%
Flight to Quality
-5.6%
Liquidity Crisis
-11.1%
Equity Crash
-2.5%
Credit Crisis
-9.7%""^M
输入文件是cma文件(IBM Cognos)
我运行以下代码。
a< -read.table(" aa.cma",header = FALSE,sep =",",stringsAsFactors = FALSE)
我收到以下错误:
Error in scan(file = file, what = what, sep = sep, quote = quote, dec = dec, :
line xxx did not have 11 elements
xxx线从上方 -3.7%。
我认为这要么是由于引用文字中的引号(参见上面文字中的"" Sharp ),要么是嵌入了sep =',& #39;和/或(未转义)' \ n'不平衡的未转义报价中的字符。
非常感谢您的帮助。
答案 0 :(得分:0)
read_csv似乎可以解决问题(读取以逗号分隔且包含引号的文件中包含引号的字符串。例如,“ a”,“ b”,“ c””,其中值为a, b和c“)