similar to: Multiple statements in tryCatch

Displaying 20 results from an estimated 4000 matches similar to: "Multiple statements in tryCatch"

2009 Jan 23
1
Returning NA from lm
Hi. I need to apply run a regression analysis for groups of data of fixed length:100 As, 100 Bs, 100 Cs etc. eg x Key Value A 1 A 21.2 A 4 A 6.5 ...repeat 96 times with differing values of A B 1 B 2.3 B NA B 6.5 ...repeat 96 times with differing values of B etc I run these against a linear model using tapply(data$Value, data$Key,FUN=regr,100)
2017 Dec 01
0
tryCatch in on.exit()
Thanks -- will look into it. luke On Fri, 1 Dec 2017, William Dunlap via R-devel wrote: > 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
2023 May 18
1
suprising behaviour of tryCatch()
... or just put the R expression inside curly brackets, e.g. tryCatch({ sexsnp[i] = fisher.test(table(data[,3], data[,i+38]))$p }, error=function(e) print(NA)) Exercise: Compare > list(a = 2) $a [1] 2 with > list({ a = 2 }) [[1]] [1] 2 and > list(b = { a = 2 }) $b [1] 2 BTW, note how the latter two assigned a <- 2 to the global environment. /Henrik On Thu, May 18, 2023 at
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
2005 Oct 18
0
tryCatch, simpleCondition question
Hi, I'm trying to learn how to use the tryCatch condition system and am confused about the behavior when I set the call arg of a simpleCondition. I want to catch an error if it meets a certain criteria and otherwise reraise it. I want the error message to indicate the function in which the error occured (and not mention tryCatch). Wanted: > g("foo") ## error caught
2012 Mar 17
0
tryCatch interferes with traceback(), debugger(), dump.frames()....
I want to use tryCatch, but tryCatch seems to obscure important things I need for debugging. For example, say I am working with an SQLite database, and have written this function: debugThisFunction <- function(dbfile) { require(RSQLite) drv <- SQLite() conn <- dbConnect(drv, dbfile) tryCatch({ dbBeginTransaction(conn) tryCatch({ for (i in 1:10) {
2023 May 18
1
suprising behaviour of tryCatch()
Because `<-` and `=` do different things (and I am one of the old fossils that wish they had not been confounded). `fun(x <- expr)` Assigns the value of `expr` to the variable `x` in the frame/environment that `fun` is called from. `fun(x = expr)` Assigns the value of `expr`to the variable `x` in the frame/environment created for and used by `fun` subject to the rules of argument matching.
2011 May 04
1
tryCatch?
I would like to do inserts into a database table, but do updates in the fairly rare cases in which the inserts fail. I thought tryCatch might be the way to do it, but I honestly do not understand the help file for tryCatch at all. I thought something like this might work: for (i in seq(along = tbl$key)) { tryCatch(sqlSave(pg, tbl[i, ], "tbl", append = TRUE, rownames = FALSE),
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 =
2008 Sep 01
0
tryCatch
> I am trying to debug a program, and I think tryCatch will help. The > functions involved > process through so many times before I encounter the error, things > are a bit slow to > use debug and browser(). > > I've read the help file and postings on conditions, and am still > having trouble. > > While running my program I am getting a NAN from a called
2011 Mar 10
1
tryCatch - Continuing for/next loop after error
Dear all, I am not sure I understand fully the functionality of "tryCatch" and "try" commands and how these are used to continue a for/next loop if an error occurs within the loop. Can somebody point me to material (or share some code) with more extensive examples than the ones in the help/FAQ pages? Do explain my problem in more detail: for (i in 100:1000) { ## do
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
2011 Jul 10
1
Help with tryCatch
Having a hard time understanding the help files for tryCatch. Looking for a little help with the following statement which sits inside a for loop zest[i] <- tryCatch(sapply(getNodeSet(zdoc, "//zestimate/amount"), xmlValue), error=function() zest[i] <-"NA") zest is a numeric vector If the sapply statement evaluates to an error, I'd like to set the value of zest[i]
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
2015 May 28
2
problemas con tryCatch
Buenos días, Quiero hacer una función con un "if", que si devuelve un error dentro de él se pare la ejecución de la función devolviendo un valor. El código que tengo, para las pruebas, es el siguiente: prueba<-function(a){ b<-"no ha hecho stop" c<-"hago el stop" if(a<3){ variable<-"hola" tryCatch({ write("entro en el
2019 Sep 15
0
[External] REprintf could be caught by tryCatch(message)
On Sun, 15 Sep 2019, Jan Gorecki wrote: > Dear R-devel community, > > There appears to be an inconsistency in R C API about the exceptions > that can be raised from C code. > Mapping of R C funs to corresponding R functions is as follows. > > error -> stop > warning -> warning > REprintf -> message This is wrong: REpintf is like cat with file = stderr().
2017 Dec 14
0
cannot destroy connection (?) created by readLines in a tryCatch
On Thu, Dec 14, 2017 at 12:17 PM, G?bor Cs?rdi <csardi.gabor at gmail.com> wrote: > On Thu, Dec 14, 2017 at 7:56 PM, Gabriel Becker <gmbecker at ucdavis.edu> > wrote: > > Gabor, > > > > You can grab the connection and destroy it via getConnection and then a > > standard close call. > > Yeah, that's often a possible workaround, but since this
2019 Sep 16
0
[External] REprintf could be caught by tryCatch(message)
You can file it as a wishlist item in the bug trackign system. Without a compelling case or a complete and well tested patch or both I doubt it will rise to the top of anyone's priority list. Best, luke On Sun, 15 Sep 2019, Jan Gorecki wrote: > Thank you Luke for prompt reply. > Is it possible then to request a new function to R C API "message" > that would equivalent to
2018 May 22
0
Using tryCatch in a for loop
(practically) ALWAYS respond to the list. I have cc'ed them here. Others may (almost always do!) have greater insight/better answers than I. In this case, I have no clue, but presumably your call is wrong, but as I have no experience with the segmented.lm function, I don't care to track down how exactly. Your tryCatch call seems to be fine, however. -- Bert Bert Gunter "The
2023 May 17
4
suprising behaviour of tryCatch()
Hello, I run a fisher.test() in a loop, with the issue that some of the data will not be useable. To protect the loop I used tryCatch but: 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] =" But this works: for(i in