在ddply崩溃中抛出错误R [英] Error thrown within ddply crashes R

查看:115
本文介绍了在ddply崩溃中抛出错误R的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到一个问题,当从提供的函数发出错误时,plyr一直崩溃。

 > require(plyr)
加载所需的包:plyr
警告消息:
包plyr是在R 3.0.2版本下构建的
> df< - data.frame(group = c(A,A,B,B),num = c(11,22,33,44))
> ddply(df,。(group),function(x){x})
group num
1 A 11
2 A 22
3 B 33
4 B 44

> ddply(df,。(group),function(x){stop(badness)})
从:(function()
{
.rs.breakOnError(TRUE)
})()
.fun(piece,...)中的错误:badness
浏览[1]>
#立即崩溃

有人知道为什么会发生这种情况,以及如何防止它(除了当然避免错误)?



(我正在平台上运行R 3.0.1:i386-w64-mingw32 / i386(32位)通过RStudio

EDIT
作为解决方法,我将任何错误重定向为避免崩溃的警告

  ddply(df,。(group),function(x)tryCatch(stop(badness),error = function )警告(e)))

如果我设法调整plyr和R

解决方案

我在R 3.1.1和plyr 1.8.1上也有同样的问题。



要修复它,我只是从源代码重新安装包。

  install.packages(plyr ,type =source)


I'm running into an issue where plyr consistently crashes when an error is thrown from the supplied function

> require(plyr)
Loading required package: plyr
Warning message:
package ‘plyr’ was built under R version 3.0.2 
> df <- data.frame(group=c("A","A","B","B"), num=c(11,22,33,44))
> ddply(df, .(group), function(x) {x})
  group num
1     A  11
2     A  22
3     B  33
4     B  44

> ddply(df, .(group), function(x) {stop("badness")})
called from: (function ()
{
     .rs.breakOnError(TRUE)
})()
Error in .fun(piece, ...) : badness
Browse[1]>
# Crashes immediately

Is anyone aware of why this may be occuring and how to prevent it (other than avoiding errors of course)?

(I'm running R 3.0.1 on platform: i386-w64-mingw32/i386 (32-bit) through RStudio 0.98.274 under Windows 7)

EDIT As a workaround, I am redirecting any errors as warnings which avoids the crashes

ddply(df, .(group), function(x) tryCatch(stop("badness"), error = function(e) warning(e)) )

Will report what happens here if I manage to align the plyr and R versions.

解决方案

I got the same issue on R 3.1.1 and plyr 1.8.1.

To fix it, I just reinstalled the package from source.

install.packages("plyr", type = "source")

这篇关于在ddply崩溃中抛出错误R的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆