相关疑难解决方法(0)

成功将分页JSON对象强制转换为R数据帧

我试图将从API中提取的JSON转换为R中的数据帧,以便我可以使用和分析数据.

#Install needed packages
require(RJSONIO)
require(httr)

#request a list of companies currently fundraising using httr
r <- GET("https://api.angel.co/1/startups?filter=raising")
#convert to text object using httr
raise <- content(r, as="text")
#convert to list using RJSONIO
fromJSON(raise) -> new
Run Code Online (Sandbox Code Playgroud)

一旦我得到这个对象,new我就很难将列表解析成数据帧.json有这样的结构:

{
  "startups": [
 {
  "id": 6702,
  "name": "AngelList",
  "quality": 10,
  "...": "...",
  "fundraising": {
    "round_opened_at": "2013-07-30",
    "raising_amount": 1000000,
    "pre_money_valuation": 2000000,
    "discount": null,
    "equity_basis": "equity",
    "updated_at": "2013-07-30T08:14:40Z",
    "raised_amount": 0.0
      }
    }
  ],
  "total": 4268 ,
  "per_page": 50,
  "page": 1,
  "last_page": …
Run Code Online (Sandbox Code Playgroud)

r httr jsonlite

6
推荐指数
2
解决办法
3509
查看次数

标签 统计

httr ×1

jsonlite ×1

r ×1