【发布时间】:2013-09-29 16:31:01
【问题描述】:
我很困惑为什么在与 ddply 和 .parallel=TRUE 一起使用时似乎无法找到“logging”包中的 loginfo 方法。
这是一个突出问题的示例。该示例使用 ddply 按物种计算平均萼片长度。如果 .parallel=FALSE,此代码将按预期工作。但如果 .parallel=TRUE 则抱怨找不到 'loginfo' 方法。
library(logging)
library(doSNOW)
registerDoSNOW(cl <- makeCluster(4, type="SOCK"))
data(iris)
ddply(iris, .(Species), function(iris) {
loginfo("now working with %s", unique(iris$Species)) # if parallel, can't find function?!
mean(iris$Sepal.Length)
}, .parallel=TRUE)
stopCluster(cl)
--
Error in do.ply(i) : task 1 failed - "could not find function "loginfo""
In addition: Warning messages:
1: <anonymous>: ... may be used in an incorrect context: ‘.fun(piece, ...)’
2: <anonymous>: ... may be used in an incorrect context: ‘.fun(piece, ...)’
【问题讨论】:
-
您可能需要将函数导出到从站。
-
好的,谢谢。那就是问题所在。这就是我需要做的... clusterEvalQ(cl, library(logging))
标签: r parallel-processing