similar to: tryCatch

Displaying 20 results from an estimated 9000 matches similar to: "tryCatch"

2008 Dec 23
1
Borders for rectangles in lattice plot key
Hopefully an easy question. When drawing a rectangles in a lattice plot key, how do you omit the black borders? Here is an example adapted from one on the xyplot help page: bar.cols <- c("red", "blue") key.list <- list( space="top", rectangles=list(col=bar.cols), text=list(c("foo", "bar")) ) barchart( yield ~ variety | site,
2009 Jan 09
1
Saving plots as byte streams
Is it possible to save plots as byte streams? For example, if I want the bytes for a PNG plot, I could use #Write the plot to a PNG file png("test.png") plot(1:10) dev.off() #Read the bytes back in from the file plotbytes <- readBin("test.png", "raw", n=2000) Ideally, I'd like to avoid having to bother writing to the file in the first place, and simply
2008 Sep 26
2
adjusting textsize and spacing in mosaic (vcd package)
I'm trying to find a way to change the font size in a mosaic plot (the grid version, not the base graphics one). Here's an example to demonstrate: #Basic plot library(vcd) mosaic(HairEyeColor, shade = TRUE) #Bad first guess: this stops the default cell colouring, and doesn't change the font size mosaic(HairEyeColor, shade = TRUE, gp=gpar(fontsize=16)) #This successfully changes
2009 Nov 16
2
n=1 default for random number generators
One tiny thing that would be very nice to have is a default value of n=1 in the random number generator functions, enabling, e.g., runif() instead of runif(1). This won't break anyone's existing code and ought to be relatively straightforward to do. Is there anyone in the core team who would be willing to include this change? ----- Regards, Richie. Mathematical Sciences Unit HSL --
2008 Sep 05
1
controlling lattice plot ticks with relation="free"
How do you persuade lattice to draw tick marks on both the left and right side of the y-axis, when relation="free" in the scales component? #Ticks appear on both sides histogram(~height|voice.part, data=singer) ##Ticks only on left histogram(~height|voice.part, data=singer, scales=list(y=list(relation="free"))) Providing tck as a vector of length 2 doesn't seem to
2008 Jul 23
1
select significant variables
Hi, I want to do significant variables selection for continuous/discrete dependent variables. I am wondering what the best package or what the best method should be used. Thank you for your time. Best regards, Brandon _________________________________________________________________ [[elided Hotmail spam]] [[alternative HTML version deleted]]
2007 Dec 19
1
Different labels by panel in barchart
Dear all, I'm analysing a survey, and creating a barchart of the different responses for each question. The questions are grouped according to a number of categories, so I'm using lattice to create a plot with each question in a category on it. The problem is that the response set for different questions within the same category varies. I want to be able to draw only the relevant
2009 Jan 12
2
R2WinBUGS stopping execution
Apologies if this isn't acceptable for the general help list. I'm running OpenBUGS model via the R2WinBUGS package interface, under Windows. Is it possible to terminate running models, short of using the Windows Task Manager to forcibly exit the program? Regards, Richie. Mathematical Sciences Unit HSL ------------------------------------------------------------------------
2008 May 06
1
Spacing between lattice panels
I'm trying to set up a lattice plot with two y-axes for each panel. (Yes, I know that multiple y-axes are generally a bad idea; the graph is for someone else and they want it that way.) I've used a custom yscale.component in xyplot to achieve this: myyscale.component <- function(...) { ans <- yscale.components.default(...) ans$right <- ans$left foo <-
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 Oct 17
1
Using key.opts in Ecdf/labcurve (Hmisc package)
I'm presumably missing something very obvious, but how does one use the key.opts argument in labcurve (via Ecdf)? In this example, I want the key to be big and have a blue background, but it isn't and doesn't. ch <- rnorm(1000, 200, 40) sex <- factor(sample(c('female','male'), 1000, TRUE)) Ecdf(~ch, group=sex, label.curves=list(keys=c("f",
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