简体   繁体   English

R多个函数变为lapply

[英]R multiple functions into lapply

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. 我有一个字符向量中的URL列表,我想暂停查询之间的过程,因为如果不是x查询被拒绝。

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

here is want I want to do 这是我想做的

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

As Justin suggested, formatting is the key. 正如贾斯汀所说,格式化是关键。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM