为什么plyr包不使用我的并行后端?

编程入门 行业动态 更新时间:2024-10-21 22:51:42
本文介绍了为什么plyr包不使用我的并行后端?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试在R中将parallel包用于并行操作,而不是doSNOW,因为它是内置的,表面上是R Project想要的方式.我做错了我无法确定的事情.例如:

I'm trying to use the parallel package in R for parallel operations rather than doSNOW since it's built-in and ostensibly the way the R Project wants things to go. I'm doing something wrong that I can't pin down though. Take for example this:

a <- rnorm(50) b <- rnorm(50) arr <- matrix(cbind(a,b),nrow=50) aaply(arr,.margin=1,function(x){x[1]+x[2]},.parallel=F)

这很好,产生了我两列的总和.但是,如果我尝试引入并行程序包:

This works just fine, producing the sums of my two columns. But if I try to bring in the parallel package:

library(parallel) nodes <- detectCores() cl <- makeCluster(nodes) setDefaultCluster(cl) aaply(arr,.margin=1,function(x){x[1]+x[2]},.parallel=T)

它引发错误

2: In setup_parallel() : No parallel backend registered 3: executing %dopar% sequentially: no parallel backend registered

我初始化后端错误吗?

推荐答案

尝试以下设置:

library(doParallel) library(plyr) nodes <- detectCores() cl <- makeCluster(nodes) registerDoParallel(cl) aaply(ozone, 1, mean,.parallel=TRUE) stopCluster(cl)

由于我从未使用plyr进行并行计算,所以我不知道为什么会发出警告.无论如何,结果是正确的.

Since I have never used plyr for parallel computing I have no idea why this issues warnings. The result is correct anyway.

更多推荐

为什么plyr包不使用我的并行后端?

本文发布于:2023-10-30 04:27:39,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1541765.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:后端   plyr

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!