1

当我遇到意外问题时,我试图调试我正在处理的 parLapply 函数:parLapply 的 MoreArgs 参数不起作用!现在是凌晨 5 点,我一定很累,错过了一些非常明显和愚蠢的东西,但我终生无法看到它是什么。无论如何,这是给我带来麻烦的最小示例:

require(parallel)

cluster <- makeCluster(3)
testFUN <- function(n=10, min=0, max=100, outname="test1.Rdata"){
    nums <- runif(n, min=min, max=max)
    total <- sum(nums)
    save(total, file = outname)
    return(total)

}


#just to make sure the function works
testFUN(n=5, min=4, max=150, outname = "test0.Rdata")

#make sure the cluster can get the functions
clusterExport(cluster, list("testFUN", "runif", "sum", "save"))
nlist <- list(first=5, second=10, third=15)
parLapply(cl = cluster, nlist, testFUN, outname=c("test1.Rdata", "test2.Rdata", "test3.Rdata"), MoreArgs=list(min=33, max=110))

stopCluster(cluster)

输出是:

Error in checkForRemoteErrors(val) : 
  3 nodes produced errors; first error: unused argument (MoreArgs = list(min = 33, max = 110))
4

0 回答 0