I am loading this JSON data with 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": {}
}
Which results in a structure with nested data frames
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"))
I'd like to create a single data.frame that looks like this:
Type | Name | latencyAvg | latencyMax | latencyStdev | totalRequests | startTime | endTime
json | duda | 201.40us | <etc..>
update | duda | 201.40us | <etc..>
By flatting the nested data frames. I'm figuring out how to do this manually by removing the items I want and using rbind/cbind to move them into a new data frame, but is there a simple way to do this type of recursive flattening?