You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, I am looping over rows of a data frame and doing some computation. Sometimes that computation throws an error for a specific row. I wrap everything in a tryCatch where adply correctly returns the value inside my error handler.
Error in try(.fun(piece, ...)) : bad value
Error: with piece 3:
a b
3 3 3
xxx
Error: object 'xxx' not found
The pain point is that downstream I am expecting the variable xxx to exist, whether it's V1 column is populated with values from Catch or it is populated from values with Try. If I have message(e) in the error handler the variable xxx never gets set
The text was updated successfully, but these errors were encountered:
Hello, I am looping over rows of a data frame and doing some computation. Sometimes that computation throws an error for a specific row. I wrap everything in a tryCatch where adply correctly returns the value inside my error handler.
grid = data.frame(a = 1:3, b = 1:3)
xxx = adply(grid, 1, function(i) {
tryCatch({
if(any(i == 3)) {
stop("bad value")
} else {
return (4)
}
}, error = function(e) {
test = 2+3
return (test)
})
}, .inform=T)
Correctly returns xxx is
a b V1
1 1 1 4
2 2 2 4
3 3 3 5
Now if my error handler also prints a message about the error, e, adply fails.
grid = data.frame(a = 1:3, b = 1:3)
xxx = adply(grid, 1, function(i) {
tryCatch({
if(any(i == 3)) {
stop("bad value")
} else {
return (4)
}
}, error = function(e) {
message(e)
test = 2+3
return (test)
})
}, .inform=T)
Error in try(.fun(piece, ...)) : bad value
Error: with piece 3:
a b
3 3 3
The pain point is that downstream I am expecting the variable xxx to exist, whether it's V1 column is populated with values from Catch or it is populated from values with Try. If I have message(e) in the error handler the variable xxx never gets set
The text was updated successfully, but these errors were encountered: