rOpenGov / rtimes

R wrapper for NYTimes API for government data - ABANDONED

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

First 10 rows not returning in article search

elinw opened this issue · comments

Hi,

This is a really great package.
I was using all_results= TRUE and I noticed that the first 10 rows were never being returned (the rows in "data" are always 10 less than the number in hits. It's because of the odd way that R uses & and && and in this case you really want just & because you only want to run the special code when the number of hits is greater than 10, not to only run it when, basically, the hit number is great than 10.

#23

I wanted to attach the screenshots showing what I mean even though I think my suggestion about how to fix it is wrong. I think you really need to prepend 0 to the pgs vector.

screen shot 2018-03-18 at 4 47 48 pm
screen shot 2018-03-18 at 4 47 10 pm

how are nyt_wcc_time_1 and nyt_wcc_time_0 created?

I think we already do this correctly (but let me know if not) - that is, the first request is made here

https://github.com/rOpenGov/rtimes/blob/master/R/as_search.R#L71-L72

regardless of what parameter value all_results is set to. Then if all_results is TRUE and there are more than 10 records found, then we do the for loop to grab all results here

https://github.com/rOpenGov/rtimes/blob/master/R/as_search.R#L74-L89

and here https://github.com/rOpenGov/rtimes/blob/master/R/as_search.R#L89 we combine the first http request results with those results from the for loop

Hi. I got the same error. Here is the answer:

The error is still in the CRAN package
install.packages("rtimes")

The error is fixed in the development version from GitHub
install.packages("devtools")
devtools::install_github("ropengov/rtimes")

thanks for the note @BenjaminGitHub1 , good to know.