Displaying 20 results from an estimated 30000 matches similar to: "How to catch a R error in R code"
2007 Oct 19
2
Help deeded: Does a R graphical function return something special?
Hi All,
When I tried to catch a returned value from a R graphical
function or command (e.g., plot, lines, points, abline, title,
xyplot, etc.), I always get a NULL value if it is executed
correctly. For example:
x <- c(1,2,3,4,5,9,13,19,36)
plot.Comm <- plot(x) # plot.Comm <- try(eval(plot(x)))
then plot.Comm has a NULL value. Obviously, this is not a good way
to check if or
2013 Mar 19
1
source, sys.source and error line numbers
Hi,
is there a way to retrieve the line number of where en error occurred when
sourcing a file in a tryCatch statement? Is it stored somewhere accessible?
It is not found in the error object.
Consider the following code/output and note the difference in the traceback
between source (has line number) and sys.source (has no line number).
Thank you,
Renaud
########
# code
########
codefile <-
2012 Feb 23
1
segfault when using data.table package in conjunction with foreach
Hi all,
I'm trying to use the package read.table within a foreach loop. I'm
grabbing 500M rows of data at a time from two different files and then
doing an aggregate/tapply like function in read.table after that. I
had planned on doing a foreach loop 39 times at once for the 39 files
I have, but obviously that won't work until I figure out why the
segfault is occurring. The
2013 Nov 15
1
Inconsistent results between caret+kernlab versions
I'm using caret to assess classifier performance (and it's great!). However, I've found that my results differ between R2.* and R3.* - reported accuracies are reduced dramatically. I suspect that a code change to kernlab ksvm may be responsible (see version 5.16-24 here: http://cran.r-project.org/web/packages/caret/news.html). I get very different results between caret_5.15-61 +
2010 Mar 31
1
You are right and the problem is solved. Re: about the possible errors in Rgraphviz Package
Hi Martin,
It is really a 'PATH' problem. After adding C:\Program
Files\Graphviz2.20\bin to the 'PATH' environment variable, the
Rgraphviz package can be loaded without any error messages.
Sorry that I ONLY set my 'PATH' environment variable correctly
for R but not for Graphviz.
Thank you and Duncan so much for your great help.
Howard
On Tue Mar 30 18:12:54
2010 Mar 30
8
about the possible errors in Rgraphviz Package
Hi All,
I tried to install the package of Rgraphviz in the following two
ways successfully:
source("http://bioconductor.org/biocLite.R")
biocLite("Rgraphviz")
install.packages(pkgs="C:/Progra~1/R/lib_download/Rgraphviz_1.24.0.zip",
lib="C:/Progra~1/R/R-2.10.1/library", repos=NULL)
but when I loaded the package though library(Rgraphviz) or
2008 May 30
2
scoping problem when calling lm(precomputed formula, weights) from function (PR#11540)
I've run into a scoping problem in R.
I'm calling a function that
* creates a formula
* calculates a weight vector
* calls lm with that formula and weights
This fails.
Here's a simplified reproduce example:
# f works, g doesn't, h is a workaround
rm(w)
data <- data.frame(y=runif(20), x=runif(20), z=runif(20))
f <- function(k){
w <- data$z^k
coef(lm(y~x, data
2009 Dec 30
1
seg-fault... but on what
I got the following after running succesfully through this loop 28 million
times... the loop opens text files in a directory and inserts line by line
into a database...
*** caught segfault ***
address 0xc0000010, cause 'memory not mapped'
Traceback:
1: .getGeneric(f, where, package)
2: getGeneric("coerce", where = where)
3: as(obj, "integer")
4:
2019 Feb 27
1
stopifnot
My points:
- The 'withCallingHandlers' construct that is used in current 'stopifnot' code has no effect. Without it, the warning message is the same. The overridden warning is not raised. The original warning stays.
- Overriding call in error and warning to 'cl.i' doesn't always give better outcome. The original call may be "narrower" than 'cl.i'.
I
2007 Oct 10
0
Thank you, and your suggestion works
Hi Jim,
What you told me works well.
I have tried using 'eval(parse(text="1:20 = x"))' as well as
'try(parse(text="1:20 = x"))' before but not using eval anfd try
functions together. I just added try function following your
suggestion, e.g. 'try(eval(parse(text="1:20 = x")))'and then it
worked well.
Thank you very much for the nice
2001 May 30
2
environments
I would like to be able, inside a function, to create a new function, and
use it as part of a formula as an argument to, say, gnls or nlme. for
example:
MyTop <- function(data=dta) {
Cexp <- function(dose,A,B,m){...}
Model <- as.formula(paste("y","~ Cexp(",paste(formals(Cexp),collapse
=", "),")"))
MyCall <-
2010 Nov 11
3
Evaluation puzzle
The survexp function can fail when called from another function. The "why" of
this has me baffled, however.
Here is a simple test case, using a very stripped down version of survexp:
survexp.test <- function(formula, data,
weights, subset, na.action, rmap,
times, cohort=TRUE, conditional=FALSE,
ratetable=survexp.us, scale=1, npoints, se.fit,
2016 Nov 15
2
Missing objects using dump.frames for post-mortem debugging of crashed batch jobs. Bug or gap in documentation?
Martin, thanks for the good news and sorry for wasting your (and others
time) by not doing my homework and query bugzilla first (lesson learned!
).
I have tested the new implementation from R-devel and observe a semantic
difference when playing with the parameters:
# Test script 1
g <- "global"
f <- function(p) {
l <- "local"
dump.frames()
}
2007 May 27
2
Question about "evalq"
The help page of eval says: The 'evalq' form is equivalent to
'eval(quote(expr), ...)'. But the following is not equivalent. Can
anyone give me some explaination? Thanks very much.
> f1 <- function(x,digits=5) lapply(x, f2)
> f2 <- function(x) eval(quote(print(x+1,digits=digits)),list(x=x),parent.frame(2))
> f1(list(x1=1))
[1] 2
$x1
[1] 2
>
> f1 <-
2019 Feb 24
1
stopifnot
>From https://github.com/HenrikBengtsson/Wishlist-for-R/issues/70 :
... and follow up note from 2018-03-15: Ouch... in R-devel, stopifnot() has become yet 4-5 times slower;
...
which is due to a complete rewrite using tryCatch() and withCallingHandlers().
>From https://stat.ethz.ch/pipermail/r-devel/2017-May/074256.html , it seems that 'tryCatch' was used to avoid the following
2007 Nov 28
3
using names with functions..
Dear all,
I have the following (rather) strange problem..
For some reasons, I finally work with a variable whose name includes an
R function, "a.log(z)", say. And that is a problem when I call it in a
formula, for instance:
> myname<-"a.log(z)"
> dd<-data.frame("a.log(z)"=1:10,y=rnorm(10))
> o<-lm(y~1,data=dd)
>
2007 Dec 27
2
Problem of lmer under FreeBSD
I encounter such problem with lmer under FreeBSD, but not under
Windows. Anyone knows why? Thanks.
> example(lmer)
lmer> (fm1 <- lmer(Reaction ~ Days + (Days|Subject), sleepstudy))
Error in UseMethod("as.logical") : no applicable method for "as.logical"
> traceback()
9: as.logical(EMverbose)
8: as.logical(EMverbose)
7: lmerControl()
6:
2006 Nov 21
1
strange R GUI crash
Hi all,
I know I shouldn't really expect the following to work, but it
provokes a crash of the GUI on my computer (Win xp professional).
---
>sessionInfo()
Version 2.3.1 (2006-06-01)
i386-pc-mingw32
attached base packages:
[1] "methods" "stats" "graphics" "grDevices" "utils" "datasets"
[7] "base"
2016 Nov 13
2
Missing objects using dump.frames for post-mortem debugging of crashed batch jobs. Bug or gap in documentation?
Dear R friends,
to allow post-mortem debugging In my Rscript based batch jobs I use
tryCatch( <R expression>,
error = function(e)
{
dump.frames(to.file = TRUE)
})
to write the called frames into a dump file.
This is similar to the method recommended in the "Writing R extensions"
manual in section 4.2 Debugging R code (page 96):
2012 Oct 16
2
gam (mgcv) problem: Error in while (mean(ldxx/(ldxx + ldss)) > 0.4) { :, missing value where TRUE/FALSE needed
Hi All,
I'm running into a problem with GAM (in the MGCV package). When I try
to estimate the model, I get the following error message:
1> fit <-
gam(ndvi~s(rain)+s(temp)+s(rainl1)+s(rainl2)+s(rainxY)+s(rainl1xY)+s(rainl2xY)+s(tempxY),
data=dsub, weights=wvec)
Error in while (mean(ldxx/(ldxx + ldss)) > 0.4) { :
missing value where TRUE/FALSE needed
Using