1
返回嵌套數據幀我加載該JSON數據與jsonlite如何從壓扁jsonlite
<snip>
"rawData": {
"fortune": {},
"plaintext": {},
"db": {},
"update": {
"duda": [
{
"latencyAvg": "201.40us",
"latencyMax": "727.00us",
"latencyStdev": "54.85us",
"totalRequests": 561810,
"startTime": 1413890149,
"endTime": 1413890164
}
]
},
"json": {
"duda": [
{
"latencyAvg": "201.40us",
"latencyMax": "727.00us",
"latencyStdev": "54.85us",
"totalRequests": 561810,
"startTime": 1413890149,
"endTime": 1413890164
}
]
},
"query": {}
}
其中在結構嵌套數據幀的結果
data <- structure(list(fortune = structure(list(), .Names = character(0)),
plaintext = structure(list(), .Names = character(0)), db = structure(list(), .Names = character(0)),
update = structure(list(duda = structure(list(latencyAvg = "201.40us",
latencyMax = "727.00us", latencyStdev = "54.85us", totalRequests = 561810L,
startTime = 1413890149L, endTime = 1413890164L), .Names = c("latencyAvg",
"latencyMax", "latencyStdev", "totalRequests", "startTime",
"endTime"), class = "data.frame", row.names = 1L)), .Names = "duda"),
json = structure(list(duda = structure(list(latencyAvg = "201.40us",
latencyMax = "727.00us", latencyStdev = "54.85us", totalRequests = 561810L,
startTime = 1413890149L, endTime = 1413890164L), .Names = c("latencyAvg",
"latencyMax", "latencyStdev", "totalRequests", "startTime",
"endTime"), class = "data.frame", row.names = 1L)), .Names = "duda"),
query = structure(list(), .Names = character(0))), .Names = c("fortune",
"plaintext", "db", "update", "json", "query"))
我想創建一個單個數據幀如下所示:
Type | Name | latencyAvg | latencyMax | latencyStdev | totalRequests | startTime | endTime
json | duda | 201.40us | <etc..>
update | duda | 201.40us | <etc..>
通過平鋪嵌套的數據幀。我想通過刪除我想要的項目並使用rbind/cbind將它們移動到新的數據框中來手動執行此操作,但是有沒有簡單的方法來執行此類遞歸展平?
您需要提供什麼將是未來可能的安排和名稱將出現始終是兩個命名項'json'和'update'? – 2014-10-21 23:44:34
JSON示例完全覆蓋了我期望看到的數據 - 第一個嵌套框架將具有名稱json,update,query等。第二個嵌套幀將有latencyAvg,latencyStdev等。預計JSON數據沒有其他安排 – Hamy 2014-10-21 23:46:43
你是怎麼用'jsonlite'加載的?在寫入文件之後,我一直試圖加載它幾次,並且我無法加載它沒有錯誤 – 2014-10-22 02:28:02