Error when using %dopar% instead of %do% in R (package doParallel)

后端 未结 3 1524
慢半拍i
慢半拍i 2021-01-14 01:12

I\'ve come up with a strange error. Suppose I have 10 xts objects in a list called data. I now search for every three combinations using

   data_names <-          


        
3条回答
  •  抹茶落季
    2021-01-14 01:39

    The problem is likely that you haven't called library(xts) on each of the workers. You don't say what backend you're using, so I can't be 100% sure.

    If that's the problem, then this code will fix it:

    list <- foreach(i=1:ncol(combs)) %dopar% {
        library(xts)
        tmp_triple <- combs[,i]
    
        p1<-data[tmp_triple[[1]]][[1]]
        p2<-data[tmp_triple[[2]]][[1]]
        p3<-data[tmp_triple[[3]]][[1]]
    
        data.merge <- merge(p1,p2,p3,all=FALSE)
    }
    

提交回复
热议问题