Displaying 20 results from an estimated 10000 matches similar to: "matching last argument in function"
2012 Oct 19
2
setting option in function
is it possible to set an option inside a function ((I want to set
na.action = na.fail) and have the previous state restored if there is
an error so that the function doesn't change the option behind the
user's back?
Sorry if this has been answered before, but this subject is hard to Google.
--
Charles Geyer
Professor, School of Statistics
University of Minnesota
charlie at stat.umn.edu
2011 Sep 01
1
parser does not catch strings without closing quote
Shouldn't the parser complain about unfinished strings in files?
It doesn't and will tack on a newline if there isn't one there.
> withOption <- function(optionList, expr) {
+ oldOption <- options(optionList)
+ on.exit(options(oldOption))
+ expr
+ }
> cat(file=tf<-tempfile(), "\"string without closing quote\n")
> p <-
2007 May 17
2
Scoped options setting?
Is there any way to set options during the evaluation of a particular
expression, with them automatically reset when control leaves that
expression, however that happens? Kind of like "let" on a "special"
variable does in Lisp. I naively tried
with(options(warn=-1), {
fit <- fitdistr(data, 'weibull') # complains about NaNs
})
but this leaves
2018 Nov 22
2
[tryExcept] New try Function
Hi everyone,
When dealing with errors, sometimes I want to run a bunch of code when an error occurs.
For now I usually use a structure such as:
res <- tryCatch(expr, error = function(cond) cond) # or try(expr)
if (inherits(res, ?error?)) # or inherits(res, ?try-error?)
# a bunch of code
I though it would be useful to have a function that does this naturally, so I came up with the attached
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 27
3
[LLVMdev] Proposal for better assertions in LLVM
wrapping the macro's body in:
do { ... } while (false)
would make the the macro a proper statement so that:
if (cond)
ASSERT(some_other_cond);
else
do_something_cool ();
compiles as expected.
IMO, it would work as such
#define ASSERT_STM(cond,expr)
On Tue, Jul 26, 2011 at 6:36 PM, Reid Kleckner <reid.kleckner at gmail.com>wrote:
> He wants to be able to resume execution
2018 Nov 23
1
[tryExcept] New try Function
Hi Emil,
First, thanks for the response. As you mentioned, a lot of times tryCatch
does the work, as you can return a value. However, sometimes it is useful
to assign several variables when an error occurs. You could do it with <<-,
but I prefer to reduce it's usage unless completely necessary.
I guess that the attachment was missed in the moderation. Here it is the
function:
2016 May 04
4
Is it possible to retrieve the last error? (not error *message*)
Hi,
at the R prompt, is it possible to retrieve the last error (as in
condition object of class "error")?
I'm not asking for geterrmessage(), which only returns the error
message (as a character string). I'm basically looking for a
.Last.error or .Last.condition, analogously to .Last.value for values,
which can be used when it is "too late" (not possible) to go back
2011 Jul 27
0
[LLVMdev] Proposal for better assertions in LLVM
sorry, my previous message got sent too early
I think the macro should look something like this:
#define ASSERT_STRM(cond,expr) \
do {
if (cond) {
std::cerr << expr << std::end;
assertion_trap ();
}
} while (false)
On Tue, Jul 26, 2011 at 7:57 PM, Nathan Jeffords <blunted2night at gmail.com>wrote:
> wrapping the macro's body in:
>
> do { ... } while
2009 Mar 18
2
incoherent conversions from/to raw
i wonder about the following examples showing incoherence in how type
conversions are done in r:
x = TRUE
x[2] = as.raw(1)
# Error in x[2] = as.raw(1) :
# incompatible types (from raw to logical) in subassignment type fix
it seems that there is an attempt to coerce the raw value to logical
here, which fails, even though
as.logical(as.raw(1))
# TRUE
likewise,
x[2]
2009 Mar 18
2
incoherent conversions from/to raw
i wonder about the following examples showing incoherence in how type
conversions are done in r:
x = TRUE
x[2] = as.raw(1)
# Error in x[2] = as.raw(1) :
# incompatible types (from raw to logical) in subassignment type fix
it seems that there is an attempt to coerce the raw value to logical
here, which fails, even though
as.logical(as.raw(1))
# TRUE
likewise,
x[2]
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.
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
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
2010 Nov 16
2
Debugging segfault in foreach
Hi,
I'm using R-2.12 on a linux 64bit machine.
When I run a chunk of code inside a foreach() %do% { ...} or %dopar%
{...} (with doMC backend) I keep getting a segfault. Running the
*same* code within lapply(something, function(x) ... ) doesn't result
in any segfaults. I'll paste the output below, but I'm not sure it
would be helpful.
I'm more curious how to go about smoking
2013 Jun 07
1
cannot load pbdMPI package after compilation
Hello,
I try to install pbdMPI.
Compilation successful, but load fails with segfault.
Is anyone can help me?
R version 3.0.0
pbdMPI version 0.1-6
Intel compiler version 13.1.1
OpenMPI version 1.6.4-1
CPU Intel x86_64
# R CMD INSTALL pbdMPI_0.1-6.tar.gz
..
....
checking for gcc... icc -std=gnu99
checking whether the C compiler works... yes
checking for C compiler default output file name...
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 <-
2019 Sep 15
2
[External] REprintf could be caught by tryCatch(message)
Thank you Luke for prompt reply.
Is it possible then to request a new function to R C API "message"
that would equivalent to R "message" function? Similarly as we now
have C "warning" and C "error" functions.
Best,
Jan
On Sun, Sep 15, 2019 at 5:25 PM Tierney, Luke <luke-tierney at uiowa.edu> wrote:
>
> On Sun, 15 Sep 2019, Jan Gorecki wrote:
2012 May 15
1
KEGGSOAP installation error
Hello,
I'm trying to install KEGGSOAP with bioconductor but i'm facing this
problem:
/> biocLite("KEGGSOAP")
BioC_mirror: http://bioconductor.org
Using R version 2.15, BiocInstaller version 1.4.4.
Installing package(s) 'KEGGSOAP'
trying URL
'http://www.bioconductor.org/packages/2.10/bioc/src/contrib/KEGGSOAP_1.30.0.tar.gz'
Content type
2009 Mar 20
1
sprintf causes a segfault (PR#13613)
Full_Name: Wacek Kusnierczyk
Version: 2.8.0 and 2.10.0 r48163
OS: Ubuntu 8.04 Linux 32bit
Submission from: (NULL) (129.241.198.172)
the following code illustrates a problem with sprintf which consistently causes
a segfault when applied to certain type of arguments. it also shows
inconsistent consequences of the segfault:
(e = tryCatch(stop(), error=identity))
# e is an error object