我尝试使用rgbif-api下载特定国家的生物多样性数据,代码为country
我试试这个
library(rgbif)
dfexample <- dataset_search(country="US", limit = 30)
有可能制作成数据帧吗?
就目前情况来看,这个问题还不清楚。
> names(dfexample)
#[1] "meta" "data" "facets" "descriptions"
sapply(dfexample,class)
$meta
#-----
[1] "data.frame"
$data
[1] "tbl_df" "tbl" "data.frame"
$facets
[1] "NULL"
$descriptions
[1] "list"
sapply(dfexample, length)
#------
meta data facets descriptions
4 8 0 30
如果你希望数据元素是一个数据帧,那么它已经是一个tibble了,所以只需提取它:
dfexample$data # might be what you wanted
您可以使用str查看tbl_df中的列名。它的行为应该像普通R函数的数据帧:
str(dfexample$data)
tibble [30 × 8] (S3: tbl_df/tbl/data.frame)
$ datasetTitle : chr [1:30] "EOD – eBird Observation Dataset" "GBIF Backbone Taxonomy" "Catalogue of Life - June 2021" "NCBI Taxonomy" ...
$ datasetKey : chr [1:30] "4fa7b334-ce0d-4e88-aaae-2e0c138d049e" "d7dddbf4-2cf0-4f39-9b2a-bb099caae36c" "7ddf754f-d193-4cc9-b351-99906754a03b" "fab88965-e69d-4491-a04d-e3198b626e52" ...
$ type : chr [1:30] "OCCURRENCE" "CHECKLIST" "CHECKLIST" "CHECKLIST" ...
$ hostingOrganization : chr [1:30] "Cornell Lab of Ornithology" "GBIF Secretariat" "The Catalogue of Life Partnership" "GBIF Secretariat" ...
$ hostingOrganizationKey : chr [1:30] "e2e717bf-551a-4917-bdc9-4fa0f342c530" "fbca90e3-8aed-48b1-84e3-369afbd000ce" "f4ce3c03-7b38-445e-86e6-5f6b04b649d4" "fbca90e3-8aed-48b1-84e3-369afbd000ce" ...
$ publishingOrganization : chr [1:30] "Cornell Lab of Ornithology" "GBIF Secretariat" "The Catalogue of Life Partnership" "National Center for Biotechnology Information (NCBI)" ...
$ publishingOrganizationKey: chr [1:30] "e2e717bf-551a-4917-bdc9-4fa0f342c530" "fbca90e3-8aed-48b1-84e3-369afbd000ce" "f4ce3c03-7b38-445e-86e6-5f6b04b649d4" "2f2e4f28-d929-4609-937b-9a8ebd265159" ...
$ publishingCountry : chr [1:30] "US" NA NA "US" ..