ropensci / aRxiv
1
# check if a search will return too many results
2
is_too_many <-
3
function(query=NULL, id_list=NULL, start=0, limit=10)
4
{
5
    # look for delay amount in options; otherwise set to default
6 1
    toomany <- getOption("aRxiv_toomany")
7 1
    if(is.null(toomany)) toomany <- 15000
8

9
    # this is to avoid having to call arxiv_count twice
10 1
    expected_number <- NA
11

12 1
    if(is.null(start))
13 0
        start <- 0
14 1
    if(is.null(limit))
15 1
        limit <- expected_number <- arxiv_count(query, id_list)
16

17 1
    stopifnot(start >= 0)
18 1
    stopifnot(limit >= 0)
19

20 1
    if(limit > toomany) {
21 1
        if(is.na(expected_number)) # haven't yet called arxiv_count
22 1
            expected_number <- arxiv_count(query, id_list)
23 1
        message("Total records matching query: ", expected_number)
24

25 1
        if(expected_number > toomany)
26 1
            return(expected_number)
27
    }
28

29 1
    0 # return 0 if it's not too many
30
}

Read our documentation on viewing source code .

Loading