I love using plyr
, but sometimes the underlying data throws an error that I can't locate.
For instance, I've created a summing function that throws an error if x == 8
:
df <- data.frame(x = rep(1:10,3), y = runif(30))
ddply(df,
.(x),
function (z) {
if(z$x[1] == 8) {
stop("There's an error somewhere.")
}
return(sum(z$y))
})
Pretending I didn't know what had caused the error, is there any way to report which rows of data caused the error?