
Selecting and ordering variables
William K. Morris
Source:vignettes/v03_selecting_variables.Rmd
v03_selecting_variables.RmdWhen requesting data using finbif you can select from
among (or order by) many variables (properties of the occurrence
records). The default set of variables returned is a small subset of
those available. Note that not all variables are available for all
records. See ?variables for details.
Selecting variables
Limiting variables
To retrieve a limited set of variables from FinBIF simply specify the
desired variables in the select argument.
finbif_occurrence(
genus = "Falco",
select = c("scientificName", "lifeStage", "sex")
)Click to show/hide output.
#> Records downloaded: 10
#> Records available: 488726
#> A data.frame [10 x 3]
#> scientificName lifeStage sex
#> 1 Falco rusticolus Li… <NA> Female
#> 2 Falco peregrinus Tu… <NA> <NA>
#> 3 Falco subbuteo Linn… <NA> <NA>
#> 4 Falco columbarius L… <NA> <NA>
#> 5 Falco columbarius L… <NA> <NA>
#> 6 Falco tinnunculus L… <NA> <NA>
#> 7 Falco columbarius L… <NA> Female
#> 8 Falco tinnunculus L… <NA> Female
#> 9 Falco tinnunculus L… <NA> Female
#> 10 Falco vespertinus L… juvenile <NA>Extra variables
To get extra variables as well as the default set, specify the extra
variables in addition to the keyword "default_vars".
finbif_occurrence(select = c("default_vars", "lifeStage"))Click to show/hide output.
#> Records downloaded: 10
#> Records available: 61187886
#> A data.frame [10 x 13]
#> occurrenceID scientificName individualCount decimalLatitude decimalLongitude
#> 1 …21 Polytrichum juniper… NA 60.17967 24.914629
#> 2 …25 Polytrichum juniper… NA 60.373472 24.993816
#> 3 …29 Polytrichum juniper… NA 61.612783 21.44191
#> 4 …33 Polytrichum juniper… NA 61.322069 23.513515
#> 5 …37 Polytrichum juniper… NA 61.249458 25.040691
#> 6 …41 Polytrichum juniper… NA 62.605448 25.925676
#> 7 …45 Polytrichum juniper… NA 62.22789 30.629365
#> 8 …49 Polytrichum juniper… NA 66.004079 28.202282
#> 9 …53 Polytrichum juniper… NA 69.049179 20.812003
#> 10 …57 Polytrichum pilifer… NA 60.373472 24.993816
#> ...with 0 more records and 8 more variables:
#> coordinateUncertaintyInMeters, hasIssues, requiresVerification, requiresIdentification,
#> occurrenceReliability, identificationVerificationStatus, eventDate, lifeStageOrdering
You can change the order of occurrence records before they are
fetched from the server by using the order_by argument. The
default ordering is eventDateStart descending, then
documentLoadedDate descending, then
verbatimIdentification.
Ascending order
By default occurrence records are ordered by variables in ascending order.
finbif_occurrence("Cygnus cygnus", order_by = "individualCount")Click to show/hide output.
#> Records downloaded: 10
#> Records available: 141480
#> A data.frame [10 x 12]
#> occurrenceID scientificName individualCount decimalLatitude decimalLongitude
#> 1 …0745928 Cygnus cygnus (Linn… NA 66 29.25
#> 2 …0745932 Cygnus cygnus (Linn… NA NA NA
#> 3 …0745937 Cygnus cygnus (Linn… NA NA NA
#> 4 …0745941 Cygnus cygnus (Linn… NA 60.17 25
#> 5 …0745945 Cygnus cygnus (Linn… NA 60.17 25
#> 6 …0745949 Cygnus cygnus (Linn… NA 60.17 25
#> 7 …5552466 Cygnus cygnus (Linn… 1 67.773235 25.050461
#> 8 …5552474 Cygnus cygnus (Linn… 1 68.713901 22.787894
#> 9 …6082839 Cygnus cygnus (Linn… 1 NA NA
#> 10 …7079647 Cygnus cygnus (Linn… NA 61.85 23.5
#> ...with 0 more records and 7 more variables:
#> coordinateUncertaintyInMeters, hasIssues, requiresVerification, requiresIdentification,
#> occurrenceReliability, identificationVerificationStatus, eventDateDescending order
You can switch to descending order by prefixing the variable with a dash.
finbif_occurrence("Cygnus cygnus", order_by = "-individualCount")Click to show/hide output.
#> Records downloaded: 10
#> Records available: 141480
#> A data.frame [10 x 12]
#> occurrenceID scientificName individualCount decimalLatitude
#> 1 …MHU.2981587 Cygnus cygnus (Linn… 6000 64.4
#> 2 …HR.3691/OBS2052501157_Unit Cygnus cygnus (Linn… 2065 64.50736
#> 3 …HR.3691/OBS2052518008_Unit Cygnus cygnus (Linn… 2065 64.50736
#> 4 …HR.3691/OBS1101526155_Unit Cygnus cygnus (Linn… 1760 62.16389
#> 5 …HR.3691/OBS604642304_Unit Cygnus cygnus (Linn… 1753 64.50736
#> 6 …HR.3691/OBS663568887_Unit Cygnus cygnus (Linn… 1600 65.98787
#> 7 …HR.3691/OBS1399623409_Unit Cygnus cygnus (Linn… 1580 64.50736
#> 8 …MHU.28815250 Cygnus cygnus (Linn… 1500 NA
#> 9 …HR.3691/OBS671353848_Unit Cygnus cygnus (Linn… 1361 64.71656
#> 10 …HR.3691/OBS1686954463_Unit Cygnus cygnus (Linn… 1333 64.50734
#> ...with 0 more records and 8 more variables:
#> decimalLongitude, coordinateUncertaintyInMeters, hasIssues, requiresVerification,
#> requiresIdentification, occurrenceReliability, identificationVerificationStatus,
#> eventDateMultiple variables
You can specify multiple variables to order by. Sorting primacy is from left to right.
finbif_occurrence(
"Cygnus olor", order_by = c("finnishCountyID", "-individualCount")
)Click to show/hide output.
#> Records downloaded: 10
#> Records available: 63416
#> A data.frame [10 x 12]
#> occurrenceID scientificName individualCount decimalLatitude decimalLongitude
#> 1 …12015253 Cygnus olor (J.F. G… 2500 NA NA
#> 2 …13633876 Cygnus olor (J.F. G… 1500 NA NA
#> 3 …780984 Cygnus olor (J.F. G… 1300 NA NA
#> 4 …781416 Cygnus olor (J.F. G… 1300 NA NA
#> 5 …2062563 Cygnus olor (J.F. G… 1200 NA NA
#> 6 …10352894 Cygnus olor (J.F. G… 1100 NA NA
#> 7 …927797 Cygnus olor (J.F. G… 1050 NA NA
#> 8 …3110953 Cygnus olor (J.F. G… 960 NA NA
#> 9 …26309317 Cygnus olor (J.F. G… 900 NA NA
#> 10 …1260385 Cygnus olor (J.F. G… 800 58.66 23.57
#> ...with 0 more records and 7 more variables:
#> coordinateUncertaintyInMeters, hasIssues, requiresVerification, requiresIdentification,
#> occurrenceReliability, identificationVerificationStatus, eventDateRandom sample
You can also request a random sample (random order) of occurrence
records by setting the sample argument to
TRUE.
finbif_occurrence(sample = TRUE)Click to show/hide output.
#> Records downloaded: 10
#> Records available: 61186982
#> A data.frame [10 x 12]
#> occurrenceID scientificName individualCount
#> 1 …JX.1566601#3 Columba palumbus Li… 2
#> 2 …MKH.20101025#432 Chroicocephalus rid… 20
#> 3 …JX.757655#4 Eupithecia icterata… 1
#> 4 …KE.67/13087202#Unit Acrocephalus schoen… 1
#> 5 …KE.67/5980995#Unit Jynx torquilla Linn… 1
#> 6 …HR.3211/49101786-U Ranunculus acris L. NA
#> 7 …KE.881/67582b0a-81fa-4489-ba7d-57710a1ab996_Unit Betula L. 1
#> 8 …KE.67/2658108#Unit Somateria mollissim… 1
#> 9 …KE.67/15184231#Unit Sylvia atricapilla … 1
#> 10 …MKC.18447413 Carex canescens L. NA
#> ...with 0 more records and 9 more variables:
#> decimalLatitude, decimalLongitude, coordinateUncertaintyInMeters, hasIssues,
#> requiresVerification, requiresIdentification, occurrenceReliability,
#> identificationVerificationStatus, eventDate