【问题标题】:Logging with Plyr in Parallel=TRUE使用 Plyr 并行记录=TRUE
【发布时间】: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


【解决方案1】:

我需要专门将库导出到从站。谢谢,康拉德。

clusterEvalQ(cl, library(logging))

【讨论】:

    猜你喜欢
    • 2012-05-14
    • 2018-05-15
    • 2021-02-25
    • 1970-01-01
    • 1970-01-01
    • 2022-01-26
    • 1970-01-01
    • 1970-01-01
    • 2013-01-29
    相关资源
    最近更新 更多