similar to: Capturing warnings with capture.output

Displaying 20 results from an estimated 20000 matches similar to: "Capturing warnings with capture.output"

2009 Feb 04
2
Capturing all warnings (with messages)
Dear all, For an open-source project that I'm working on (1), which uses R for all its heavy lifting but includes a wrapper shell script, I was hoping to find a way to capture all warnings (and, in fact, errors too), and handle them in my own way. I realise I can do this for a single expression using something like: > f <- function(w) print(w$message) >
2009 Sep 02
1
Tracebacks & try
Hi all, The help for traceback states: Errors which are caught _via_ 'try' or 'tryCatch' do not generate a traceback, so what is printed is the call sequence for the last uncaught error, and not necessarily for the last error. Is there any way to get a traceback (or something similar) for an error raised inside a try block? Regards, Hadley -- http://had.co.nz/
2015 Sep 10
2
Using IDs to suppress specific messages and warnings
Thanks Luke, On 10 September 2015 at 14:47, <luke-tierney at uiowa.edu> wrote: > Conditions have classes and the condition system is designed around > the idea that classes would be used for this sort of thing. That is > already how tryCatch and withCallingHandlers discriminate the > conditions to handle. That makes sense. Though with my sqrt example, it's just a plain
2012 Feb 03
1
Resume processing after warning handler.
Dear list! I have a script that processes a large number of data files. When one file fails to process correctly, I want the script to write a message and to continue with the next file. I achieved this with tryCatch: for (f in files) tryCatch({heavy.lifting(f)}, error=function(e) log.error.to.file(e)) I also want to log warning messages and tried something like this: for (f in
2004 Jun 10
1
tryCatch() and preventing interrupts in 'finally'
With tryCatch() it is possible to catch interrupts with tryCatch(). Then you can use a 'finally' statement to clean up, release resources etc. However, how can I "protect" against additional interrupts? This is a concern when the hold down Ctrl+C and generates a sequence of interrupts. Example: tryCatch({ cat("Press Ctrl+C...\n"); Sys.sleep(5); }, interrupt =
2005 Sep 07
1
Tracebacks with tryCatch() and withCallingHandlers()?
When batch processing analysis, I use tryCatch() for failure handling and to prevent unwanted interrupts. I write detailed progress to log file and conditions (warnings and errors) are written to the same log file immediately by using withCallingHandlers(..., condition=function(c) cat(c, file=logFile)). However, I would also like to write the call stack to the log file to further simplify
2018 Mar 06
1
Capturing warning within user-defined function
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 Dunlap TIBCO Software wdunlap tibco.com On Tue, Mar 6, 2018 at 2:45 PM, Bert Gunter <bgunter.4567 at
2019 Feb 24
1
stopifnot
>From https://github.com/HenrikBengtsson/Wishlist-for-R/issues/70 : ... and follow up note from 2018-03-15: Ouch... in R-devel, stopifnot() has become yet 4-5 times slower; ... which is due to a complete rewrite using tryCatch() and withCallingHandlers(). >From https://stat.ethz.ch/pipermail/r-devel/2017-May/074256.html , it seems that 'tryCatch' was used to avoid the following
2010 Aug 24
3
require is to suggests as what is to imports?
Hi all, If a package suggests another package in its description, you can check it at runtime with requires. How do you do check if a package is available without loading it, if you only want to access one function in the package namespace. Thanks, Hadley -- Assistant Professor / Dobelman Family Junior Chair Department of Statistics / Rice University http://had.co.nz/
2019 Feb 27
1
stopifnot
My points: - The 'withCallingHandlers' construct that is used in current 'stopifnot' code has no effect. Without it, the warning message is the same. The overridden warning is not raised. The original warning stays. - Overriding call in error and warning to 'cl.i' doesn't always give better outcome. The original call may be "narrower" than 'cl.i'. I
2020 Oct 31
2
strptime() keeps emitting warnings after establishing a handler with tryCatch()
Dear list members, I have come about a peculiar behavior in R (4.0.2) which I would describe as a bug. On macOS, where `strptime()` raises a warning for invalid timezone identifiers, the following code will continue to raise the original warning with every subsequent call to `strptime()`: ``` # attach a handler for warnings for this call only: tryCatch(strptime('2020-10-31 18:30', format
2010 Dec 05
1
How to catch both warnings and errors?
Dear expeRts, I am struggling with warning/error handling. I would like to call a function which can produce either a) normal output b) a warning c) an error Since the function is called several (thousand) times in a loop, I would like to proceed "quietly" and collect the warnings and errors [to deal with them at a later point]. I have seen constructs with tryCatch (which can
2005 Nov 23
2
TryCatch() with read.csv("http://...")
Hi, folks! I'm trying to pull in data using read.csv("my URL goes here"), and it really works fantastically. Amazing to pull in live data right off the internet, into RAM, and get busy... however... occasionally there is a server problem, or the data are not up yet, and instead of pushing through a nice CSV file, the server sends a 404 "Not Found" page... Since the
2012 Oct 08
4
Capturing environment associated with a promise
Hi all, It's possible to capture the expression associated with a promise (using substitute). Is there any way to capture the environment associated with a promise? Similarly, is there any way to tell if something is a promise without accidentally evaluating it? Thanks! Hadley -- RStudio / Rice University http://had.co.nz/
2015 Sep 10
2
Using IDs to suppress specific messages and warnings
The suppressMessages and suppressWarnings functions currently suppress all the message or warnings that are generated by the input expression. The ability to suppress only specific messages or warnings is sometimes useful, particularly for cases like file import where there are lots of things that can go wrong. Suppressing only messages that match a regular expression has rightly been rejected
2020 Nov 01
0
strptime() keeps emitting warnings after establishing a handler with tryCatch()
Hello, I cannot reproduce this behavior and, as documented, the posted code doesn't issue warnings due to a wrong timezone but I'm running sessionInfo() R version 4.0.3 (2020-10-10) Platform: x86_64-pc-linux-gnu (64-bit) Running under: Ubuntu 20.04.1 LTS Matrix products: default BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.9.0 LAPACK:
2018 Mar 06
0
Capturing warning within user-defined function
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, which I think is what you want. If not, you should probably explain why it
2010 Nov 17
2
How to catch warnings
Hello when my code executes I receive the message that were some warnings. I want to catch warning messages at run time so to print some local variables and try to understand why this warning happens. I searched on internet and I tried withCallingHandlers( which seems to work but as I used Rkward the result is awful. I get a prompt to copy paste a value only while at the same time my background
2018 May 22
3
Using tryCatch in a for loop
Hello All, I have been trying to use a for loop to run segmented regressions (from?R package segmented)?on many columns of data in a data frame with the end goal of writing a new file with the following columns: column title, breakpoint year, slope, and difference in slope. Unfortunately, when one of the columns doesn't have a breakpoint the code stops and provides?an error or warning. I
2018 Jan 10
3
Código de salida de una función R
Hola, tengo una duda de R espero me puedan ayudar. En linux, en bash si una instrucción no termina correctamente puedo obtener un código de error, por ejemplo: [rapusr en tstr200043 ~]$ ls -z ls: invalid option -- 'z' Try 'ls --help' for more information. [rapusr en tstr200043 ~]$ echo $? 2 ¿En R existe algo parecido?, por ejemplo busco algo como R> rnorm(1000O) Error: