我想将来自 HTTP 请求的数据转换为数据框。
viahttr
返回的数据格式如下,包含列标题和类型等元数据。
我想将其转换为相应的数据框: Columns based on data$columnHeaders
- 从一组定义的规则中解析(基于data$columnHeaders$dataType
或data$columnHeaders$name
似乎问题已经解决了,但是我找不到经过验证的、快速有效的解决方案。
dput()
结果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"))