在R

时间:2016-04-25 06:29:23

标签: r dataframe read.table data-science

我有一个.csv文件,遗憾的是其中一列包含一个包含逗号的字典,例如:

{"name": "Umbulharjo", "type": "Kecamatan", "level": "3", "region1": "Yogyakarta", "region2": "Yogyakarta", "region3": "Umbulharjo", "postcode": "55161"}

我怎样才能放一个"在R之前的每个{和之后}之前?然后我可以设置"当我使用read.csv或read.csv2或read.table

时作为引用

2 个答案:

答案 0 :(得分:1)

您的数据看起来像是JSON-ish。如果你正在做很多JSON的事情,我建议使用library that understands JSON

答案 1 :(得分:0)

paste('{"name": "Umbulharjo", "type": "Kecamatan", "level": "3", "region1": "Yogyakarta", "region2": "Yogyakarta", "region3": "Umbulharjo", "postcode": "55161"}', '')
#[1] "{\"name\": \"Umbulharjo\", \"type\": \"Kecamatan\", \"level\": \"3\", \"region1\": \"Yogyakarta\", \"region2\": \"Yogyakarta\", \"region3\": \"Umbulharjo\", \"postcode\": \"55161\"} "