Skip to content
Prev 163999 / 398506 Next

Finding the first value without warning in a loop

Try this:

for (x in c(-2, 2, 4)) {
	tryCatch({
		y <- log(x)
		xx <- x
		break
	}, warning = function(w) {})
}
print(xx) # 2



On Sun, Dec 7, 2008 at 2:38 AM, Andreas Wittmann
<andreas_wittmann at gmx.de> wrote: