[R] Trycatch in R

2015-12-22 Thread Archit Soni
Hi All, Please help me in the below code: tryCatch({ x <- capture.output(XML::xmlParse(y)) }, warning = function(w) { x <- capture.output(w) }, error = function(e) { x <-capture.output(e) }, finally = { }) I am using Tibco Enterprise Runtime for R to get value of the parsed XML in vector f

[R] tryCatch interferes with traceback(), debugger(), dump.frames()....

2012-03-16 Thread Peter Meilstrup
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) tryCa

[R] tryCatch in a package

2012-03-07 Thread Sebastian P. Luque
Hi, Suppose we have a general function that returns a logical indicating which values in 'x' are found in 'l', throwing an error if none are found and a warning if only some are found: "checkFun" <- function(l, x) { xinl <- x %in% l if (! any(xinl)) stop("none of the x values found in l")

Re: [R] tryCatch with integration

2011-10-31 Thread William Dunlap
lto:r-help-boun...@r-project.org] On > Behalf Of statfan > Sent: Sunday, October 30, 2011 6:24 PM > To: r-help@r-project.org > Subject: [R] tryCatch with integration > > I am trying to compute the approximate numerical integration of the following > expression using the integr

[R] tryCatch with integration

2011-10-30 Thread statfan
I am trying to compute the approximate numerical integration of the following expression using the integrate function: > (integrate(function(x) {log(1+x^2)*(1+x^2)^(-20.04543)},low,Inf)$val) Error in integrate(function(x) { : the integral is probably divergent which gives me an error. If

Re: [R] tryCatch?

2011-05-04 Thread Mikkel Grum
4/11, Prof Brian Ripley wrote: > From: Prof Brian Ripley > Subject: Re: [R] tryCatch? > To: "Mikkel Grum" > Cc: "R Help" > Date: Wednesday, May 4, 2011, 12:21 PM > Start with try(): you may find it > easier to understand. > > if(inherits(try(),

Re: [R] tryCatch?

2011-05-04 Thread Prof Brian Ripley
Start with try(): you may find it easier to understand. if(inherits(try(), "try-error")) so in your case if(inherits(try(sqlSave(pg, tbl[i, ], "tbl", append = TRUE, rownames = FALSE sqlUpdate(pg, tbl[i, ], index = "key") or some such. On Wed, 4 May 2011, Mikke

[R] tryCatch?

2011-05-04 Thread Mikkel Grum
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 = t

Re: [R] tryCatch - Continuing for/next loop after error

2011-03-10 Thread Jonathan P Daily
11:29:59 AM: > [image removed] > > RE: [R] tryCatch - Continuing for/next loop after error > > William Dunlap > > to: > > Jonathan P Daily, Nipesh Bajaj > > 03/10/2011 11:30 AM > > Cc: > > r-help > > > -Original Message- > &g

Re: [R] tryCatch - Continuing for/next loop after error

2011-03-10 Thread William Dunlap
> -Original Message- > From: r-help-boun...@r-project.org > [mailto:r-help-boun...@r-project.org] On Behalf Of Jonathan P Daily > Sent: Thursday, March 10, 2011 7:49 AM > To: Nipesh Bajaj > Cc: r-help@r-project.org > Subject: Re: [R] tryCatch - Continuing for/

Re: [R] tryCatch - Continuing for/next loop after error

2011-03-10 Thread Jonathan P Daily
; - Jubal Early, Firefly Nipesh Bajaj wrote on 03/10/2011 10:21:38 AM: > [image removed] > > Re: [R] tryCatch - Continuing for/next loop after error > > Nipesh Bajaj > > to: > > Jonathan P Daily > > 03/10/2011 10:21 AM > > Cc: > > r-hel

Re: [R] tryCatch - Continuing for/next loop after error

2011-03-10 Thread Nipesh Bajaj
wn Science Center > 11649 Leetown Road > Kearneysville WV, 25430 > (304) 724-4480 > "Is the room still a room when its empty? Does the room, >  the thing itself have purpose? Or do we, what's the word... imbue it." >     - Jubal Early, Firefly > > r-help-boun...@r-project

Re: [R] tryCatch - Continuing for/next loop after error

2011-03-10 Thread Jonathan P Daily
t; - Jubal Early, Firefly r-help-boun...@r-project.org wrote on 03/10/2011 03:51:15 AM: > [image removed] > > [R] tryCatch - Continuing for/next loop after error > > Costas > > to: > > r-help > > 03/10/2011 03:53 AM > > Sent by: > > r-hel

[R] tryCatch - Continuing for/next loop after error

2011-03-10 Thread Costas
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/F

[R] trycatch examples

2010-10-10 Thread Santosh Srinivas
Dear R-group, I am looking for some good examples on trycatch. Any pointers? The help manual seems quite limited. Thanks. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-pr

Re: [R] tryCatch question

2008-09-12 Thread Henrik Bengtsson
On Fri, Sep 12, 2008 at 6:02 AM, Antje <[EMAIL PROTECTED]> wrote: > Hi there, > > I have a nested call of lapply in which I do a tryCatch statement like this > > lapply(1:length(p_names), function(w_idx) { >r <- as.numeric(pos_r[[w_idx]][1]) >c <- as.numeric(pos_c[[w_idx]][1]) >

[R] tryCatch question

2008-09-12 Thread Antje
Hi there, I have a nested call of lapply in which I do a tryCatch statement like this lapply(1:length(p_names), function(w_idx) { r <- as.numeric(pos_r[[w_idx]][1]) c <- as.numeric(pos_c[[w_idx]][1]) pos <- c(r,c) lapply(1:length(p_names[[w_idx]]), function(p_idx,

Re: [R] tryCatch

2008-09-01 Thread Richard . Cotton
> 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.

[R] tryCatch

2008-08-31 Thread Redding, Matthew
Hi All R-Gurus, 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

Re: [R] tryCatch question

2008-08-14 Thread Stephen Tucker
:35 AM Subject: Re: [R] tryCatch question Read the argment descriptions and Look at the examples in ?tryCatch. The `expr' argument (i.e. the code to try) and the `finally' argument are expressions that are evaluated (via standard lazy evaluation of arguments). The error condition handlers,

Re: [R] tryCatch question

2008-08-14 Thread Luke Tierney
Read the argment descriptions and Look at the examples in ?tryCatch. The `expr' argument (i.e. the code to try) and the `finally' argument are expressions that are evaluated (via standard lazy evaluation of arguments). The error condition handlers, provided as the `...' argument in errorClass = h

[R] tryCatch question

2008-08-14 Thread rkevinburton
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 finall

Re: [R] tryCatch - return from function to main script

2008-07-15 Thread jim holtman
Can you provide an example of what you have tried. This should work: for(i in 1:4){ x <- try(yourFunction(...)) if (class(x) = "try-error") print('had a problem") } On Tue, Jul 15, 2008 at 6:59 AM, Anne-Marie Ternes <[EMAIL PROTECTED]> wrote: > Dear helpers, > > I've got a main script, w

[R] tryCatch - return from function to main script

2008-07-15 Thread Anne-Marie Ternes
Dear helpers, I've got a main script, which calls 4 times a function on 4 different datasets respectively. This function runs "nls" and is located in another R script which is sourced into my main script. What I would like to have is this: If, e.g. in the 3rd call of the function, nls fails, bec