library(naturecounts) library(dplyr)
In naturecounts
, by default default data is downloaded with a specific set of fields/columns. However, for more advanced applications, users may wish to specify which fields/columns to return. The Bird Monitoring Data Exchange (BMDE) schema keeps track of variables used to augment observation data. There are different versions reflecting different collections of variables.
The following examples use the "testuser" user which is not available to you. You can quickly sign up for a free account of your own to access and play around with these examples. Simply replace
testuser
with your own username.
There are several ways to get more information about these different field/columns sets.
meta_bmde_versions()
function.meta_bmde_versions()
meta_bmde_fields()
functionmeta_bmde_fields(version = "BMDE-BAND-2.00") %>% head()
meta_collections() %>% head()
By default, the BMDE2.00-min
or minimum
BMDE version is used when downloading data, but you can specify other versions with either the version name, or the shorthand.
cardinals <- nc_data_dl(species = 19360, fields_set = "core", collection = "ABATLAS2", verbose = FALSE, username = "testuser", info = "nc_vignette") names(cardinals)
Note that there are extra fields/columns downloaded in every request, which are in addition to the BMDE fields. These are additional, basic, indexed fields used in the database.
You can figure out exactly which fields these are, by removing all the fields from the core
BMDE field set.
names(cardinals)[!names(cardinals) %in% meta_bmde_fields(version = "core")$local_name]
The basic fields will always be included in any data request. However, you can choose which fields/columns to include in addition to these basic fields, by specifying fields_set = custom
, and listing all additional fields
.
cardinals <- nc_data_dl(species = 19360, fields_set = "custom", fields = c("Sex", "SamplingEventIdentifier"), collection = "ABATLAS2", verbose = FALSE, username = "testuser", info = "nc_vignette") head(cardinals)
In a more complex example, if you wished to download data with the minimum
set of BMDE fields, but including a couple of extra fields, you could combine the core fields with the extras you want, and pass them on as a custom field set.
For example, first collect the minimum field/column names.
my_fields <- meta_bmde_fields(version = "minimum")$local_name my_fields
Then add in the extra fields.
my_fields <- c(my_fields, "Sex", "LifeStage") my_fields
Now download the data.
cardinals <- nc_data_dl(species = 19360, fields_set = "custom", fields = my_fields, collection = "ABATLAS2", verbose = FALSE, username = "testuser", info = "nc_vignette") head(cardinals)
Great!
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.