pageWhile: Utility function to page through results until done.

View source: R/pageWhile.R

pageWhileR Documentation

Utility function to page through results until done.

Description

Utility function to page through results until done.

Usage

pageWhile(FUN = f, Step = 100, maxPages = 10, verbose = TRUE)

Arguments

FUN

anonymous function with api call to pass.

Step

numeric step size.

maxPages

numeric maximum number of pages to go through.

verbose

logical indicating whether to print page output.

Value

a list all the pages called.

Examples


## Not run: 


key = datasetkey #

f = function(datasetkey=key, ...) { # anonymous function to be run with page while
 x = list(...) # get Step and Page variables passed in by pageWhile
 prefix = "http://api.gbif.org/v1/occurrence/search?limit=0&facet=taxonKey"
 gbifapi::gbifapi(prefix %+% "&" %+% "datasetKey=" %+% datasetkey %+% "&" %+% gbifapi::pager(x$Step,x$Page))$facets[[1]]$counts
}

CL = pageWhile(FUN=f,Step=100,maxPages=1) # get pages while is not done.






## End(Not run)


jhnwllr/gbifapi documentation built on April 30, 2022, 12:55 p.m.