0

我正在lapply研究一堆 URL 以获取一些数据,并且在这个readLines(<URL>)命令中工作正常。当我切换到sfLapply代码时无法读取网页。有谁知道为什么?下面的例子

library(snowfall)
library(rlecuyer)
# looping through each combination of fruit and dish 

sfInit(parallel = T, cpus  = as.integer(Sys.getenv('NUMBER_OF_PROCESSORS')) - 1)
dtData = # lapply(
sfLapply(
   c('apple','mango','banana'),
   function(fruit) {
      cat(fruit,'\n')
      lapply(
         c('pie','shake'),
         function(dish) {
            # getting the data 
            vcTemp = readLines(paste0('https://www.google.co.in/search?q=a',dish,' ',fruit))
         }
      )
   }
)

sfStop()

我收到的错误消息是 - checkForRemoteErrors(val) 中的错误:3 个节点产生了错误;第一个错误:无法打开连接

> sessionInfo()
R version 3.1.2 (2014-10-31)
Platform: x86_64-w64-mingw32/x64 (64-bit)

locale:
[1] LC_COLLATE=English_United Kingdom.1252  LC_CTYPE=English_United Kingdom.1252   
[3] LC_MONETARY=English_United Kingdom.1252 LC_NUMERIC=C                           
[5] LC_TIME=English_United Kingdom.1252    

attached base packages:
[1] grid      stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] rpart_4.1-8      plyr_1.8.1       gridExtra_0.9.1  reshape2_1.4.1   clue_0.3-49      scales_0.2.4    
 [7] fpc_2.1-9        ggplot2_1.0.0    rlecuyer_0.3-3   snowfall_1.84-6  snow_0.3-13      data.table_1.9.4

loaded via a namespace (and not attached):
 [1] chron_2.3-45      class_7.3-12      cluster_2.0.1     colorspace_1.2-4  DEoptimR_1.0-2    digest_0.6.8     
 [7] diptest_0.75-6    flexmix_2.3-13    gtable_0.1.2      kernlab_0.9-20    labeling_0.3      lattice_0.20-30  
[13] MASS_7.3-39       mclust_4.4        modeltools_0.2-21 munsell_0.4.2     mvtnorm_1.0-2     nnet_7.3-9       
[19] prabclus_2.2-6    proto_0.3-10      Rcpp_0.11.4       robustbase_0.92-3 stats4_3.1.2      stringr_0.6.2    
[25] tools_3.1.2       trimcluster_0.1-2
4

0 回答 0