similar to: "try"ing to understand condition handling

Displaying 20 results from an estimated 9000 matches similar to: ""try"ing to understand condition handling"

2018 Jul 28
4
re-throwing an interrupt condition
Anyone knows a way to re-throw a caught interrupt condition, so that it behaves just like the original one? I.e. no error message is printed, but the execution is stopped of course. With just calling stop in the error handler, it prints the error message, or, if there is no error message (like in the original interrupt condition), another error happens. tryCatch(Sys.sleep(100), interrupt =
2003 Nov 08
1
signalCondition
Does signalCondition() only work within try-catch blocks? I expected: testSignal <- function() { error <- simpleError("An error!") signalCondition(error) } to do the same thing as testStop <- function() { error <- simpleError("An error!") stop(error) } but testSignal returns NULL without throwing an error. Have I misunderstood something?
2006 Mar 14
1
New simpleExit() condition (Was: Re: Can example() code stop the example without generating an error?)
On 3/14/06, Uwe Ligges <ligges at statistik.uni-dortmund.de> wrote: > Henrik Bengtsson wrote: > > > Hi, > > > > does anyone know if it is possible to write example code (in Rd > > examples) such that one can stop the example without generating an > > error? Example: > > > > code A > > if (cond) > > niceStop() > > code B
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 Sep 11
1
Is invokeRestart("abort") unstoppable?
Hi, I'm trying to implement an abort() method that works just like stop() but does not signal the condition such that try() and tryCatch(..., condition=...) are, contrary to stop(), effectively non-working with abort() calls. In order to achieve this, I stumbled upon invokeRestart("abort"), cf. help("invokeRestart", package="base") that reads "Restarts are
2018 Jul 28
0
re-throwing an interrupt condition
The internal code does more or less signalCondition(e) ## allows for (another) handler cat("\n") ## cleans up console invokeRestart("abort") ## jump to 'abort' restart if not handled [for back compatibility it also runs the error option code if that is set, but that may go away eventually]. A version of your example: > { +
2023 Feb 19
2
R: determine if `suppressMessages()` has been invoked
Awesome, this gets the job done. To answer your question: When using C or C++ via Rinside or within a package, those functions do not listen to suppressMessages, e.g. `Rprintf` keeps printing to the console. Since it's common to use wrapper functions in R anyway, they can run `are_messages_suppressed` and pass the information on to an explicit `verbose` argument of the C / C++ function.
2008 Aug 27
1
S4 coercion
I am extending a DBI connection by setClass("TSPostgreSQLConnection", contains=c("PostgreSQLConnection","TSdbOptions")) but the first time I use this I am getting a warning when it tries to coerce the TSPostgreSQLConnection to a PostgreSQLConnection. After the first use the warning stops, but the first warning is causing me problems when I do automatic checks
2004 Mar 11
2
No traceback available when using try(...)
Hello, 1. The Situation : ------------------------ The stack traceback is not available when error ouccured in a try(....) -- test.R -------------------------------- f<-function(a){ return ( log(a) ) } try(f("A")) traceback() ------------------------------------------- I get the following message : > try(f("A")) Error in log(x) : Non-numeric argument to mathematical
2008 Jun 03
1
R-2.7.0 make check failure
Hello, I am fairly new to using R and am trying to install it on my Linux machine, running Scientific Linux. I get through running 'configure' and 'make' OK, but when I run 'make check', I get the following error: make check make[1]: Entering directory `/home/gruchti/Programs/R-2.7.0/tests' make[2]: Entering directory `/home/gruchti/Programs/R-2.7.0/tests'
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/
2023 Feb 19
1
R: determine if `suppressMessages()` has been invoked
Hi all, I would like to create a function that detects if suppressMessages has been invoked upon running that same function. I was looking through {https://cran.r-project.org/doc/manuals/r-release/R-ints.html}, but I haven't found an answer. I do not understand **how** suppressMessages works. I have not received an answer on SO
2007 Aug 27
0
Suggestion: Add simpleExit condition
Hi, I would like to bring up and old suggestion [http://tolstoy.newcastle.edu.au/R/devel/06/03/4512.html] of adding an exit condition, so that for instance it is possible to silently exit from scripts and Rd examples similar to return() for functions, e.g. \examples{ require("foo") || exit("Example will not run without the 'foo' package.") ... } I know this can be
2009 Apr 14
0
top level condition handlers
Hello, I would like to establish top level condition handlers and restarts, so that I don't explicit calls to withCallingHandlers and withRestarts in many places: For example : > customError function( message ){ err <- simpleError( message ) class( err ) <- c( "customError", class( err) ) err } > withCallingHandlers( { signalCondition(customError(
2008 Jan 18
0
more help needed Re: communicate from Rterm
I think the message from Prof. Ripley refers to calling shell and system from R. There is no "system" call in Windows cmd or VBA and I am calling R from VBA. Now I want to use tryCatch to output the error to a text file and exit gracefully. My expression will be source("file.r") and that will contain file I/O and db connect+query. to exemplify I am trying with
2018 Jul 28
2
re-throwing an interrupt condition
I don't want to return a value, I want to interrupt the computation, that's why I need to re-throw . But before getting back to the user I want to run some cleanup code. G. On Sat, Jul 28, 2018 at 5:59 PM I?aki ?car <i.ucar86 at gmail.com> wrote: > > El s?b., 28 jul. 2018 a las 18:30, G?bor Cs?rdi > (<csardi.gabor at gmail.com>) escribi?: > > > > Anyone
2017 Dec 01
3
tryCatch in on.exit()
The following example involves a function whose on.exit() expression both generates an error and catches the error. The body of the function also generates an error. When calling the function wrapped in a tryCatch, should that tryCatch's error function be given the error from the body of the function, since the one from the on.exit has already been dealt with? Currently the outer tryCatch
2012 Jul 25
2
reshape -> reshape 2: function cast changed?
Hi, I used to use reshape and moved to reshape2 (R 2.15.1). Now I tried some of my older scripts and was surprised that my cast function wasn't working like before. What I did/want to do: 1) Melt a dataframe based on a vector specifying column names as measure.vars. Thats working so far: dfm <- melt(df, measure.vars=n, variable_name = "species", na.rm = FALSE) 2) Recast the
2008 Aug 14
3
tryCatch question
I would like to use the 'tryCatch' function but am having a hard time getting my head around it. In 'C' like languages try/catch/finally means try a block of statements and if any throw an error then do the statements in the catch block and then error or not always do the staements in the finally block. In 'R' as best as I can tell the block of staements in the try block is
2023 May 18
1
suprising behaviour of tryCatch()
G'day Federico, On Wed, 17 May 2023 10:42:17 +0000 "Calboli Federico (LUKE)" <federico.calboli at luke.fi> wrote: > sexsnp = rep(NA, 1750) > for(i in 1:1750){tryCatch(sexsnp[i] = fisher.test(table(data[,3], > data[,i + 38]))$p, error = function(e) print(NA))} Error: unexpected > '=' in "for(i in 1:1750){tryCatch(sexsnp[i] =" Try: R> for(i in