0
JSONデータをRJSONIOパッケージを使用してデータフレームに変換する手順は次のとおりです。下記のリンク:以下RDONを使用してJSONからDataframeに変換するときに下付きの "リスト"エラーが発生しました
How to convert JSON to Dataframe
私のデータのJSONの要約で、各フィールドはどこかに50,000の周りに、値の等しい数が含まれています。カラーフィールドの値はタイプリストで、私の推測は問題の原因となっています。私はJSON値のサンプルセットを装着しています
json
title: chr
remaining: chr
color: list()
brand: chr
modelnum: chr
size: chr
コミュニティ上の誰もが、データフレームの中にこれをモデル化する方法についていくつかの光を当てることができれば、それは素晴らしいことでしょう!
サンプルJSONデータ:
{"title":"oneplus 3","remaining":"","color":[],"brand":"OnePlus","modelnum":"OnePlus 3","size":""}
{"title":"oneplus 3 (soft gold, 64 gb)","remaining":"(soft)","color":["gold"],"brand":"OnePlus","modelnum":"OnePlus 3","size":"64 gb"}
{"title":"deal 1:oneplus 3 (graphite, 64gb) 6gb ram 4g lte - 1 year manufacture warranty","remaining":"deal 1: 6gb ram 4g lte - 1 year manufacture warranty","color":["graphite"],"brand":"OnePlus","modelnum":"OnePlus 3","size":"64gb"}
{"title":"oneplus 3 (graphite, 64 gb)","remaining":"","color":["graphite"],"brand":"OnePlus","modelnum":"OnePlus 3","size":"64 gb"}
{"title":"xiaomi redmi note 3 32gb","remaining":"","color":[],"brand":"Xiaomi","modelnum":"Redmi Note 3","size":"32gb"}
{"title":"xiaomi redmi note 3 (grey 32 gb) mobile phone","remaining":"mobile phone","color":["grey"],"brand":"Xiaomi","modelnum":"Redmi Note 3","size":"32 gb"}
{"title":"xiaomi redmi note 3 new (6 month brand warranty)","remaining":"new (6 month brand warranty)","color":[],"brand":"Xiaomi","modelnum":"Redmi Note 3","size":""}
{"title":"xiaomi redmi note 3 (gold 32gb) mobile phone","remaining":"mobile phone","color":["gold"],"brand":"Xiaomi","modelnum":"Redmi Note 3","size":"32gb"}
{"title":"xiaomi redmi note 3 (dark grey) (32gb)","remaining":"","color":["dark grey"],"brand":"Xiaomi","modelnum":"Redmi Note 3","size":"32gb"}
{"title":"mi redmi note 3 32gb dark grey","remaining":"mi","color":["dark grey"],"brand":"Xiaomi","modelnum":"Redmi Note 3","size":"32gb"}
{"title":"xiaomi redmi note 3 (gold, 32gb)","remaining":"","color":["gold"],"brand":"Xiaomi","modelnum":"Redmi Note 3","size":"32gb"}
R-コード:
library(RJSONIO)
json <- fromJSON(file_path_for_the_above_data, nullValue = NA)
dat <- lapply(json, function(j) {
as.data.frame(replace(j, sapply(j, is.list), NA))
})
エラーが発生したところです。置き換え(J、sapply(J、is.list)、NA)で
エラー: 無効添字タイプ 'リスト'
はありがとうございます。