I am trying to recursively collect data through loops. I wrote this command and it works for collecting information from 2 pages. For example,
library(jsonlite)
data1 <- fromJSON("https://www.example.com/?page=1", flatten = TRUE)
data2 <- fromJSON("https://www.example.com/?page=2", flatten = TRUE)
filings<- rbind.pages(list(data1, data2))
I was wondering if i can do this operation recursively for 300 pages. Let me know any suggestions.
library(jsonlite)
for (i in 1:300) {
datai <- fromJSON("https://www.example.com/?page=i", flatten = TRUE)
}
filings<- rbind.pages(list(data[1:300]))
To use the looping variable in a string, you'll need to use this rather unpleasant combination of
eval
,parse
andpaste
. Here's a simple exampleYour example is probably something like