ropensci / CoordinateCleaner

Automated flagging of common spatial and temporal errors in biological and palaeontological collection data, for the use in conservation, ecology and palaeontology.
https://docs.ropensci.org/CoordinateCleaner/
79 stars 21 forks source link

An error when selecting columns of interest #44

Closed evoyeyo closed 4 years ago

evoyeyo commented 4 years ago

Dear Alexander,

I was following the tutorial, and received an error at this step:

Select columns of interest

dat = dat %>% dplyr::select(species, decimalLongitude, decimalLatitude, countryCode, individualCount, gbifID, family, taxonRank, coordinateUncertaintyInMeters, year, basisOfRecord, institutionCode, datasetName)

Error: x must be a vector, not a tbl_df/tbl/data.frame/gbif object.

I have tried to solve it with https://github.com/tidyverse/dplyr/issues/5301, but couldn't find any solution so far.

Thanks in advance for any suggestion!

azizka commented 4 years ago

This is related to rgbif rather than CoordinateCleaner rgbif/#412. Try to use the latest version of rgbif and note that the return argument of occ_search is defunct now. This means that after running occ_search you need to select the data slot of the resulting object. This works:

library(rgbif)
library(dplyr)

dat <- occ_search(scientificName = "Macaca radiata", limit = 5000,
                  return = "data", hasCoordinate = T)

dat <- dat$data

dat <- dat %>%
  dplyr::select(species, decimalLongitude, decimalLatitude, countryCode, individualCount,
                gbifID, family, taxonRank, coordinateUncertaintyInMeters, year,
                basisOfRecord, institutionCode, datasetName)
azizka commented 4 years ago

I'll close this now.