Re: [R] Capturing warning within user-defined function

2018-03-06 Thread Jen
I did explore tryCatch but wasn't successful. However, I did just try your solution, William, and it worked! I just had to modify this line in my function: p <- ((svyciprop(~grp, grp1, family=quasibinomial))[1]) to p <- withWarnings((svyciprop(~grp, grp1, family=quasibinomial))[1]) Then I cou

Re: [R] Capturing warning within user-defined function

2018-03-06 Thread William Dunlap via R-help
tryCatch() is good for catching errors but not so good for warnings, as it does not let you resume evaluating the expression that emitted the warning. withCallingHandlers(), with its companion invokeRestart(), lets you collect the warnings while letting the evaluation run to completion. Bill Dunl

Re: [R] Capturing warning within user-defined function

2018-03-06 Thread Jen
Hi William, Thanks, I'll give that a shot. I tried using withCallingHandlers without success but II admit I'm not familiar with it and may have used it wrong. I'll report back. Jen On Tue, Mar 6, 2018, 5:42 PM William Dunlap wrote: > You can capture warnings by using withCallingHandlers. H

Re: [R] Capturing warning within user-defined function

2018-03-06 Thread Bert Gunter
1. I did not attempt to sort through your voluminous code. But I suspect you are trying to reinvent wheels. 2. I don't understand this: "I've failed to find a solution after much searching of various R related forums." A web search on "error handling in R" **immediately** brought up ?tryCatch, w

Re: [R] Capturing warning within user-defined function

2018-03-06 Thread William Dunlap via R-help
You can capture warnings by using withCallingHandlers. Here is an example, its help file has more information. dataList <- list( A = data.frame(y=c(TRUE,TRUE,TRUE,FALSE,FALSE), x=1:5), B = data.frame(y=c(TRUE,TRUE,FALSE,TRUE,FALSE), x=1:5), C = data.frame(y=c(FALSE,FALSE,TRUE,TRUE,TRUE)