I would like to turn data from an HTTP request into a data frame.
The via httr
returned data is in the following format, containing meta data such as column headers and type.
Id like to convert this to a corresponding data frame: Columns based on data$columnHeaders
- parsed from a defined set of rules (based on data$columnHeaders$dataType
or data$columnHeaders$name
It seems like Problem that would have already been solved, however i can't find a proven, fast & efficient solution.
The dput()
result of data
:
data <- structure(list(columnHeaders = list(structure(list(name = "ga:date",
columnType = "DIMENSION", dataType = "STRING"), .Names = c("name",
"columnType", "dataType")), structure(list(name = "ga:visitors",
columnType = "METRIC", dataType = "INTEGER"), .Names = c("name",
"columnType", "dataType"))), rows = list(c("20120912", "26121"
), c("20120913", "32003"), c("20120914", "38348"), c("20120915",
"26679"), c("20120916", "26249"), c("20120917", "29867"), c("20120918",
"31572"), c("20120919", "27576"), c("20120920", "26730"), c("20120921",
"28598"), c("20120922", "25319"), c("20120923", "27428"), c("20120924",
"33255"), c("20120925", "32071"), c("20120926", "28272"))), .Names = c("columnHeaders",
"rows"))