[R] Flushing (Reset) 'last.warning'

From: Tiago R Magalhães <tiago17_at_gmail.com>
Date: Thu, 13 Dec 2007 11:28:54 +0000

Dear members of the mailing list,

I want to fetch warnings() from a series of prop.test calls. I want to get "none" if no warning is issued, and "warning" if there is a problem.

I have looked (and relooked) at options(warn) and warning(), warnings() and 'last.warning' but to no avail. I am a biologist, so the "R language areas" are hard to fully understand.

I cannot flush the warnings before each prop.test calls; hence if there is no warning, instead of "" I get (obviously) the last.warning from the previous call. I tried to remove 'last.warning' but it won't let me (wisely…) touch the base environment.

Code below. And if anyone could give some pointers it would be great.

Thank you, kind list
collect <- vector('character', 3)
vec.1 <- c(10,19); total.1 <- c(24,35)
vec.2 <- c(5,12); total.2 <- c(50,211)

prop.test(vec.1, total.1); collect[1] <- names(warnings())
prop.test(vec.2, total.2); collect[2] <- names(warnings())
prop.test(vec.1, total.1); collect[3] <- names(warnings())

[1] ""
[2] "Chi-squared approximation may be incorrect"
[3] "Chi-squared approximation may be incorrect"

I wanted
[1] ""
[2] "Chi-squared approximation may be incorrect"
[3] ""

R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Thu 13 Dec 2007 - 11:32:38 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 13 Dec 2007 - 12:30:18 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.