R multiple functions into lapply

南笙酒味 提交于 2020-12-29 12:59:49

问题


I have a list of urls in a character vector and I want to pause the process between queries because if not the x queries is rejected.

urls=c('url1','url2','url3')

here is want I want to do

htmlpages=lapply(urls,function(x) readLines(x) Sys.sleep(0.3))

回答1:


As Justin suggested, formatting is the key.

htmlpages = lapply(
  urls,
  function(x) 
  {
    y <- readLines(x)
    Sys.sleep(0.3)
    y
  }
)


来源:https://stackoverflow.com/questions/20473952/r-multiple-functions-into-lapply

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!