导入csv文件到R新行问题 [英] Importing csv file to R new line issue
问题描述
我有一个csv文件,它有一个文本字段包含新的行字符'\\\
',所以我不能正确导入这个文件到R.我的csv行的实际上是'\r\\\
'和
I have a csv file which has a text field that contains new line character '\n', so i cannot correctly import this file into R. My csv end of line is actually '\r\n' and I want R to use it as end of line, how I can do this?
感谢
编辑:
似乎R在某些记录中忽略了我的新行字符。例如:
It seems R is ignoring my new line character in some records. An example is:
data [48,]
data[48,]
$ b b
Var1 Var2 Var3
345 blue N
b $ b
data [49,]
data[49,]
Var1 Var2 Var3
634 red N\n821,green,
data [50,]应该以821开头,
where data[50,] should start with 821,green
我使用allowEscapes = TRUE。
I am using allowEscapes=TRUE.
推荐答案
在许多csv处理实现中,您必须转义具有\\\
和其他此类代码的字段,通常使用引号或双引号。例如'this is\\\
an example'
In a lot of csv handling implementations, you have to escape fields that have \n and other such codes, usually with quotes or double-quotes. Such as 'this is\nan example'
这篇关于导入csv文件到R新行问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!