similar to: tryCatch - return from function to main script

Displaying 20 results from an estimated 9000 matches similar to: "tryCatch - return from function to main script"

2008 Jul 09
7
recursively divide a value to get a sequence
Hi, if given the value of, say, 15000, I would like to be able to divide that value recursively by, say, 5, and to get a vector of a determined length, say 9, the last value being (set to) zero- i.e. like this: 15000 3000 600 120 24 4.8 0.96 0.192 0 These are in fact concentration values from an experiment. For my script, I get only the starting value (here 15000), and the factor by which
2008 Jul 02
2
position legend below x-axis title
Dear helpers, I'm using a R script on several different datasets, which makes that axis scales may vary quite a lot from dataset to dataset. So what I'm looking for now, is how to automagically find out how to position the legend (horizontal) in the space below the x-axis title, and how to make sure that the legend is within the limits of the lower inner or outer margin? I'm aware of
2008 May 21
4
Sweave / Latex per-chapter output
Dear R-help, I am using Sweave and pdflatex to generate a large report from data contained in my database (Postgres via RODBC). Currently, I work with a single R/Sweave file, containing several "chapter" indications for the Latex engine. My master tex file sets the document class, and includes the introduction, the main Sweave file, and a conclusions and reference file. I use a makefile
2009 Sep 21
1
Pattern Matching within Vector?
Dear mailing list, I'm stuck with a tricky problem here - at least it seems tricky to me, being not really talented in pattern matching and regex matters. I'm analysing amino acid mutations by position and type of mutation. E.g. (fictitious example) in position 92, I can find L92V, L92MV, L92I... L is in this example the wild-type amino-acid, and everything behind the position number is
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
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
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]
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
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
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 =
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),
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
2011 Nov 09
3
Help with tryCatch with a for loop
Hello all, I'm a beginner in R working on a script that will produce a set of models (linear, polynomial and logistic) for each location in a dataset. However, the self-starting logistic model often fails - if this happens I would like to just skip to the next iteration of the loop using tryCatch. I've looked at a few examples and read the help file, but didn't understand tryCatch
2011 Dec 06
2
To Try or to TryCatch, I have tried to long
So after about 4 hours struggling with Try and TryCatch I am throwing in the towel. I have a more complicated function that used logspline through iterative distributions and at some point the logspline doesnt function correctly for some subsets but is fine with others so I need to be able to identify when the error occurs and stop curtailing the distribution and I think this Try or TryCatch
2019 Sep 15
2
REprintf could be caught by tryCatch(message)
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 Rprintf -> cat Rprint/cat is of course not an exception, I listed it just for completeness. The inconsistency I would like to report is
2013 Feb 13
1
R CMD in batch mode/trycatch() keeps hold on resources
HI all, I am using R (version 2.13.1) in batch mode on a server and I use trycatch() to handle the exceptions. When the code run without any exceptions, everything goes fine, however as soon as trycatch handle an error, my code works fine but R keeps hold on the folder after quiting. Therefore when I try to delete the folder it cannot... do you have any idea of which function can be the
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
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
2012 Aug 11
2
Stopping all code execution when ANY error occurs (OR error handling without try/tryCatch)
Hi all, I often run a bunch of code with Run Selection, and, after it's done running, I find there have been like 20 errors, all due to an error that occurred early in my code, which caused problems from there on. (I must then scroll up through lots of code to find it.) What I would like is for R to stop executing when an error occurs. I am aware of a few solutions: 1. Put all the code in a