I am using the function POST from httr inside the function possibly from purrr to download multiples pdfs from a vector of URLs so I can skip to the next URL if any error happens. The problem is that I need to add a Sys.sleep from one download to the next. I know how to do it with for loop, but I can't figure out how to do it with the package purrr. For example, with for loop, I would do it this way:
df<-data.frame(id=1:4,url=c("url1","url2","url3","url4"))
for (i in 1:4){
POST(df$url[i],body=body,write_disk(paste0("df$id[i]",".pdf"))
Sys.sleep(1)
}
How can use something equivalent to Sys.sleep with the purrr package?
Sys.sleep()
? – cirofdowalk2(df$id, df$url, ~{possibly(POST, NULL)(.y, body = body, write_disk(paste0(.x, ".pdf"))); Sys.sleep(1)})
– alistaire