Error thrown within ddply crashes R

假装没事ソ 提交于 2019-12-10 20:33:01

问题


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.


回答1:


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")


来源:https://stackoverflow.com/questions/19933333/error-thrown-within-ddply-crashes-r

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!