首页 > 解决方案 > 如何用 R 处理 csv 行的中断?

问题描述

我有一个需要在 R 中读取的 csv 文件,但是有些行在某些数据之间有空格,而且它不统一。

例如:

1213,2,"some_text",2323,353,"some_other_text", 454, 232, "final"
2313,2,"all_good_here",343,22,"but here it comes
the problem", 121, 232, "final"
1213,2,"some_text",2323,353,"some_other_text", 454, 232, "final"

当我使用 read.csv 从 R 中读取它时,第一列具有以下文本格式的值:

"1213",
"2313",
" the problem", 
"1213" 

所以这给我带来了很多问题:很难设置标题,结果数据框中的值错位等等。

有人知道如何处理吗?

标签: r

解决方案


推荐阅读