Displaying 20 results from an estimated 5000 matches similar to: "stopifnot message mutation"
2008 Jul 23
2
shQuote and cat
Dear R-users,
It is my understanding that cat(shQuote(a.string)) should print the origintal a.string. Is this right?
I am not sure cat() correctly prints strings which are generated by triple-shQuote():
> shQuote(shQuote("a"))
[1] "\"\\\"a\\\"\""
> cat(shQuote(shQuote(shQuote("a"))), '\n')
2008 Jul 23
2
shQuote and cat
Dear R-users,
It is my understanding that cat(shQuote(a.string)) should print the origintal a.string. Is this right?
I am not sure cat() correctly prints strings which are generated by triple-shQuote():
> shQuote(shQuote("a"))
[1] "\"\\\"a\\\"\""
> cat(shQuote(shQuote(shQuote("a"))), '\n')
2008 Oct 03
2
computing on expressions
Dear R-users,
Suppose I have an expression:
expr = expression(a>0)
and now I want to modify it to expression(a>0 & b>0). The following doesn't work:
expr = expression(expr & b>0)
What would be a good way of doing this?
Thanks,
Vadim
________________________________
Note: This email is for the confidential use of the named addressee(s) only and may contain
2008 Aug 20
1
names of return value of median
Dear R-devel,
The median() function assigns a name, "NA", to its return value if the return value is NA and the input vector has names, otherwise the names attribute is NULL. This looks strange and inconsistent with the behavior of mean().
This inconsistency becomes a problem when median() is used inside user code that relies on consistent naming convention.
Thanks,
Vadim
> foo
2008 Aug 08
1
operating on arrays of unknown dimensionality
Dear R-users,
I am looking for a way to assign to slices of arrays where dimensionality of the array is not a-priory known.
Specifically, I would like to be able to generalize the following example of dimensionality 2 to an arbitrary diminsionality:
In this example we create an array x, a smaller array y and then assign y to a slice of x.
> dimnmx <- list(c('a','b'),
2008 Mar 21
2
writintg wrappers around save()
Dear R-users,
I am trying to write a wrapper function around save() that will report the file which is being saved to.
So I thought that the followintg would do the trick, but it doesn't. I understand that 'y' is somehow not visible inside save.verbose, but don't know how to fix this.
save.verbose <- function(..., file) {
cat("save.verbose:", file, "\n")
2008 Sep 04
1
lapply(NULL, ...) returns empty list
Dear R-devel,
Is there a reason that lapply(NULL, ...) returns the empty list, rather than NULL? It seems intuitive to expect the latter, and rather counterintuitive that lapply(list(), ... ) returns the same value as lapply(NULL, ...).
> lapply(list(), function(x) 1)
list()
> lapply(NULL, function(x) 1)
list()
> version
_
platform i386-pc-mingw32
arch
2006 Mar 01
1
stopifnot() suggestion
If an expression is passed to stopifnot() which contains missing values,
then the resulting error message is somewhat baffling until you are used
to it, e.g.
> x <- y <- rep(TRUE, 10)
> y[7] <- NA
> stopifnot(x, y)
Error in if (!(is.logical(r <- eval(ll[[i]])) && all(r)))
stop(paste(deparse(mc[[i + :
missing value where TRUE/FALSE needed
A minor change to
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
2017 May 15
3
stopifnot() does not stop at first non-TRUE argument
I think Herv?'s idea was just that if switch can evaluate arguments selectively, so can stopifnot(). But switch() is .Primitive, so does it from C.
I think it is almost a no-brainer to implement a sequential stopifnot if dropping to C code is allowed. In R it gets trickier, but how about this:
Stopifnot <- function(...)
{
n <- length(match.call()) - 1
for (i in 1:n)
{
nm
2019 May 30
2
stopifnot
Here is a patch to function 'stopifnot' that adds 'evaluated' argument and makes 'exprs' argument in 'stopifnot' like 'exprs' argument in 'withAutoprint'.
--- stop.R 2019-05-30 14:01:15.282197286 +0000
+++ stop_new.R 2019-05-30 14:01:51.372187466 +0000
@@ -31,7 +31,7 @@
.Internal(stop(call., .makeMessage(..., domain = domain)))
}
2018 Mar 12
0
Bug report: override stopifnot() ?
Why don't you use
stopifnot( all(m1 == m2) )
?
Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Mon, Mar 12, 2018 at 8:15 AM, Stepan Kasal <kasal at ucw.cz> wrote:
> Hello,
> I stumbled over a problem:
> stopifnot(m1 == m2)
>
> It works with vector or matrix, but does not work for classes from Matrix
> package.
>
> In the source of stopifnot(), there is
2017 May 16
3
stopifnot() does not stop at first non-TRUE argument
switch(i, ...)
extracts 'i'-th argument in '...'. It is like
eval(as.name(paste0("..", i))) .
Just mentioning other things:
- For 'n',
n <- nargs()
can be used.
- sys.call() can be used in place of match.call() .
---------------------------
>>>>> peter dalgaard <pdalgd at gmail.com>
>>>>> on Mon, 15 May 2017 16:28:42
2018 Mar 12
2
Bug report: override stopifnot() ?
Hello,
I stumbled over a problem:
stopifnot(m1 == m2)
It works with vector or matrix, but does not work for classes from Matrix package.
In the source of stopifnot(), there is all(m1 == m2) that would just work,
but there is also is.logical(m1 == m2) that id FALSE.
Would it be possible if Matrix package redefined stopifnot() ?
(If there is a bug tracking database for package Matrix, I would
2017 May 03
2
stopifnot() does not stop at first non-TRUE argument
Hi,
It's surprising that stopifnot() keeps evaluating its arguments after
it reaches the first one that is not TRUE:
> stopifnot(3 == 5, as.integer(2^32), a <- 12)
Error: 3 == 5 is not TRUE
In addition: Warning message:
In stopifnot(3 == 5, as.integer(2^32), a <- 12) :
NAs introduced by coercion to integer range
> a
[1] 12
The details section in its man
2018 Mar 12
0
Bug report: override stopifnot() ?
Please stop this line of queries/"suggestions/speculations and read the
relevant docs **carefully**.
For example, from ?"=="
"Note
Do not use == and != for tests, such as in if expressions, where you must
get a single TRUE or FALSE. Unless you are absolutely sure that nothing
unusual can happen, you should use the identical
2017 May 19
1
stopifnot() does not stop at first non-TRUE argument
While you are fiddling with stopifnot(), please consider changing the form
of the error thrown so that it includes the caller's call. The change
would be from something like
stop( <<the message>> )
to
stop(simpleError( <<the message>>, sys.call(-1)))
For the following code
f <- function(x, y) {
stopifnot(x > y)
x - y
}
g <- function(x,
2017 May 03
2
stopifnot() does not stop at first non-TRUE argument
Not sure why the performance penalty of nonstandard evaluation would
be more of a concern here than for something like switch().
If that can't/won't be fixed, what about fixing the man page so it's
in sync with the current behavior?
Thanks,
H.
On 05/03/2017 02:26 AM, peter dalgaard wrote:
> The first line of stopifnot is
>
> n <- length(ll <- list(...))
>
>
2019 Mar 31
3
stopifnot
Ah, with R 3.5.0 or R 3.4.2, but not with R 3.3.1, 'eval' inside 'for' makes compiled version behave like non-compiled version.
options(error = expression(NULL))
library(compiler)
enableJIT(0)
f <- function(x) for (i in 1) {x; eval(expression(i))}
f(is.numeric(y))
# Error: object 'y' not found
fc <- cmpfun(f)
fc(is.numeric(y))
# Error: object 'y' not found
2019 Jan 03
2
Compiler + stopifnot bug
Hi,
I found the following issue in r-devel (2019-01-02 r75945):
`foo<-` <- function(x, value) {
bar(x) <- value * x
x
}
`bar<-` <- function(x, value) {
stopifnot(all(value / x == 1))
x + value
}
`foo<-` <- compiler::cmpfun(`foo<-`)
`bar<-` <- compiler::cmpfun(`bar<-`)
x <- c(2, 2)
foo(x) <- 1
x # should be c(4, 4)
#> [1] 3 3
If the functions