ropensci / neotoma

Programmatic R interface to the Neotoma Paleoecological Database.
https://docs.ropensci.org/neotoma
Other
30 stars 16 forks source link

`get_download()` reports too many data sets downloaded. #30

Closed gavinsimpson closed 11 years ago

gavinsimpson commented 11 years ago

This may just be an infelicity. In the example (from ?get_download())

#' t8kyr.datasets <- get_datasets(taxonname='Thuja*', loc=c(-150, 20, -100, 60), ageyoung = 8000)
#'
#' #  Returns 3 records (as of 04/04/2013), get dataset for the first record, Gold Lake Bog.
#' GOLDKBG <- get_download(t8kyr.datasets[[1]]$DatasetID)

you'll note that get-download() prints

API call was successful. Returned 2 records.

Which it does in the way get_download() counts the number of returned records, to whit

Browse[2]> str(aa, max = 3)
List of 2
 $ success: num 1
  $ data   :List of 2
  ..$ :List of 10
  .. ..$ CollUnitType   : chr "Core"
  .. ..$ DatasetName    : logi NA
  .. ..$ Samples        :List of 24
  .. ..$ DatasetPIs     :List of 2
  .. ..$ DatasetType    : chr "pollen"
  .. ..$ NeotomaLastSub : chr "6/30/2007"
  .. ..$ DefChronologyID: num 442
  .. ..$ Site           :List of 9
  .. ..$ DatasetID      : num 966
  .. ..$ CollUnitHandle : chr "GOLDLKBG"
   ..$ :List of 5
  .. ..$ DatasetType   : chr "pollen"
  .. ..$ DatasetName   : logi NA
  .. ..$ DatasetID     : num 966
  .. ..$ CollUnitType  : chr "Core"
  .. ..$ CollUnitHandle: chr "GOLDLKBG"

get_download throws away aa[[1]] and works only with aa[[2]], by which it counts the length of aa[[2]] as shown above. Then of that it only then works with aa[[2]][[1]]. In other words the list of 5 at the end is dropped.

What is the intended behaviour here? Seems the second list (aa[[2]][[2]]) duplicates some of the data in the first list (aa[[2]][[1]]). As the code ignores aa[[2]][[2]] and is coded to download only a single data set, should be just do away with counting the length of aa[[2]] and reports that a single data set was downloaded?

SimonGoring commented 11 years ago

Just pushed a change, \code{get_download} now returns just the site name along with the cheery message that the API worked.