{"action":"created","issue":{"url":"https://api.github.com/repos/ropensci/rgbif/issues/241","repository_url":"https://api.github.com/repos/ropensci/rgbif","labels_url":"https://api.github.com/repos/ropensci/rgbif/issues/241/labels{/name}","comments_url":"https://api.github.com/repos/ropensci/rgbif/issues/241/comments","events_url":"https://api.github.com/repos/ropensci/rgbif/issues/241/events","html_url":"https://github.com/ropensci/rgbif/issues/241","id":194639345,"number":241,"title":"return NA for missing fields","user":{"login":"PhillRob","id":7759348,"avatar_url":"https://avatars.githubusercontent.com/u/7759348?v=3","gravatar_id":"","url":"https://api.github.com/users/PhillRob","html_url":"https://github.com/PhillRob","followers_url":"https://api.github.com/users/PhillRob/followers","following_url":"https://api.github.com/users/PhillRob/following{/other_user}","gists_url":"https://api.github.com/users/PhillRob/gists{/gist_id}","starred_url":"https://api.github.com/users/PhillRob/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PhillRob/subscriptions","organizations_url":"https://api.github.com/users/PhillRob/orgs","repos_url":"https://api.github.com/users/PhillRob/repos","events_url":"https://api.github.com/users/PhillRob/events{/privacy}","received_events_url":"https://api.github.com/users/PhillRob/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2016-12-09T16:32:52Z","updated_at":"2016-12-10T06:36:44Z","closed_at":null,"body":"Running ```occ_search``` with ```return='data' ```and list of ```fields``` does return vectors of different length. Those are difficult to convert into data frame and filter. Fill requested fields that do not have data stored in GBIF with NA for easy processing instead of omitting those completely.\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/ropensci/rgbif/issues/comments/266183057","html_url":"https://github.com/ropensci/rgbif/issues/241#issuecomment-266183057","issue_url":"https://api.github.com/repos/ropensci/rgbif/issues/241","id":266183057,"user":{"login":"sckott","id":577668,"avatar_url":"https://avatars.githubusercontent.com/u/577668?v=3","gravatar_id":"","url":"https://api.github.com/users/sckott","html_url":"https://github.com/sckott","followers_url":"https://api.github.com/users/sckott/followers","following_url":"https://api.github.com/users/sckott/following{/other_user}","gists_url":"https://api.github.com/users/sckott/gists{/gist_id}","starred_url":"https://api.github.com/users/sckott/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sckott/subscriptions","organizations_url":"https://api.github.com/users/sckott/orgs","repos_url":"https://api.github.com/users/sckott/repos","events_url":"https://api.github.com/users/sckott/events{/privacy}","received_events_url":"https://api.github.com/users/sckott/received_events","type":"User","site_admin":false},"created_at":"2016-12-10T06:36:43Z","updated_at":"2016-12-10T06:36:43Z","body":"If i understand the problem correctly, there's a number of ways to deal with different number of columns and mismatched column names. \r\n\r\none is with `dplyr::bind_rows` like `bind_rows(data.frame(a = 5, b = 6), data.frame(a = 5, c = 7))` or with `data.table::rbindlist` like `data.table::rbindlist(list(data.frame(a = 5, b = 6), data.frame(a = 5, c = 7)), fill = TRUE, use.names = TRUE)`\r\n\r\nI think the problem may be that you're dropping the column names. if you retain those you can easily use one of the two above approaches to merge by column names, e.g., \r\n\r\n```r\r\nlibrary(rgbif)\r\nspecies<-c(2768885, 3020791)\r\ncountry<-c('AU','US','DE')\r\nfields<-c(\"name\",\"key\",\"publishingOrgKey\" , \"publishingCountry\" ,\r\n          \"basisOfRecord\" ,\"taxonKey\",\"speciesKey\",\"scientificName\",\r\n          \"species\",\"decimalLongitude\",\"decimalLatitude\" ,\"year\",\"month\", \r\n          \"day\",\"eventDate\",\"issues\",\"countryCode\",\"institutionCode\" )\r\na <- list()\r\na1 <- list()\r\nresults <- vector(\"list\")\r\nfor (i in seq_along(country)) {\r\n  for (j in seq_along(species)) {\r\n    a <- occ_search(\r\n      taxonKey = species[j],\r\n      limit = 100,\r\n      country = country[i],\r\n      return = 'data',\r\n      fields = fields\r\n    )\r\n    a<-a[!duplicated(a),]\r\n    a<-a[!duplicated(a[,\"year\"]),]\r\n    min <- min(a[[\"eventDate\"]], na.rm = TRUE)\r\n    a <- na.omit(a[a$eventDate == min, ])\r\n    results[[j]] <- a\r\n  }\r\n  a1[[i]] <- results\r\n}\r\ndplyr::bind_rows(unlist(a1, recursive = FALSE))\r\n```\r\n\r\n```r\r\n#> # A tibble: 4 × 18\r\n#>                    name        key                     publishingOrgKey publishingCountry      basisOfRecord taxonKey speciesKey\r\n#>                   <chr>      <int>                                <chr>             <chr>              <chr>    <int>      <int>\r\n#> 1          Prunus avium  992089422 47e00926-5a2f-44e8-8509-139a689c8b4d                AU PRESERVED_SPECIMEN  3021922    3020791\r\n#> 2 Asparagus officinalis 1021365283 fb702600-a84e-11de-978d-b8a03c50a862                US PRESERVED_SPECIMEN  2768885    2768885\r\n#> 3 Asparagus officinalis 1338051173 bb646dff-a905-4403-a49b-6d378c2cf0d9                DE  HUMAN_OBSERVATION  2768885    2768885\r\n#> 4          Prunus avium 1339315962 bb646dff-a905-4403-a49b-6d378c2cf0d9                DE  HUMAN_OBSERVATION  3020791    3020791\r\n#> # ... with 11 more variables: scientificName <chr>, species <chr>, decimalLongitude <dbl>, decimalLatitude <dbl>, year <int>,\r\n#> #   month <int>, day <int>, eventDate <chr>, issues <chr>, countryCode <chr>, institutionCode <chr>\r\n```"}}
{"actor":{"display_login":"sckott"}}