你可能會更好用:
library(jsonlite)
library(tibble)
library(dplyr)
res <- GET("http://mics.unicef.org/api/survey")
content(res, as="text") %>%
fromJSON(flatten=TRUE) %>%
as_tibble() %>%
glimpse()
## Observations: 312
## Variables: 11
## $ round <chr> "MICS1", "MICS1", "MICS1", "MICS1", "MICS1",...
## $ region <chr> "Central and Eastern Europe and the Commonwe...
## $ country <chr> "Croatia", "Kyrgyzstan", "Turkey", "Turkmeni...
## $ country_in_filter <chr> "Croatia", "Kyrgyzstan", "Turkey", "Turkmeni...
## $ year <chr> "1996", "1995", "1995", "1995", "1996", "199...
## $ status <chr> "Completed", "Completed", "Completed", "Comp...
## $ reports <list> [<Final, https://mics-surveys-prod.s3.amazo...
## $ archive <chr> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, ...
## $ extra_info <lgl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, ...
## $ dataset.status <chr> "Not available", "Not available", "Not avail...
## $ dataset.url <chr> "", "", "", "", "", "", "", "", "", "", "", ...
相同的數據也更多的數據。
該URL用於構建頂級過濾器行(該網站發出幾個XHR請求來構建表和過濾器行)。 CSV「導出」是一個額外的步驟,因爲您可以直接抓取XHR URL(正如我在這裏所做的那樣),所以您確實不需要額外的步驟。