Displaying 20 results from an estimated 20000 matches similar to: "Bug in comparison of language objects?"
2019 Jul 12
4
Unexpected behaviour when comparing (==) long quoted expressions
Hi everyone:
I?m one of the interns at RStudio this summer working on a project that
helps teachers grade student code. I found an unexpected behaviour with
the |==| operator when comparing |quote|d expressions.
Example 1:
|u <- quote(tidyr::gather(key = key, value = value,
new_sp_m014:newrel_f65, na.rm = TRUE)) s <- quote(tidyr::gather(key =
key, value = value,
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
2019 Mar 02
1
stopifnot
A private reply by Martin made me realize that I was wrong about
stopifnot(exprs=TRUE) .
It actually works fine. I apologize. What I tried and was failed was
stopifnot(exprs=T) .
Error in exprs[[1]] : object of type 'symbol' is not subsettable
The shortcut
assert <- function(exprs) stopifnot(exprs = exprs)
mentioned in "Warning" section of the documentation similarly fails
2012 Feb 06
1
Segfault on ".C" registration via R_CMethodDef according to 'Writing R Extensions'.
Dear R List,
I encountered a serious problem regarding the registration of ".C" when following the documentation "Writing R Extensions"
that leads to a segmentation fault (tested on windows and mac os x).
The registration mechanism for ".C" routines via R_registerRoutines and
the R_CMethodDef structure has been enhanced recently with the
addition of two fields, one
2007 Dec 09
1
List comprehensions for R
Below is code that introduces a list comprehension syntax into R,
allowing expressions like:
> .[ sin(x) ~ x <- (0:11)/11 ]
[1] 0.00000000 0.09078392 0.18081808 0.26935891 0.35567516 0.43905397
[7] 0.51880673 0.59427479 0.66483486 0.72990422 0.78894546 0.84147098
> .[ .[x*y ~ x <- 0:3] ~ y <- 0:4]
[,1] [,2] [,3] [,4] [,5]
[1,] 0 0 0 0 0
[2,] 0 1 2
2019 Mar 05
2
stopifnot
Another possible shortcut definition:
assert <- function(exprs)
do.call("stopifnot", list(exprs = substitute(exprs), local = parent.frame()))
After thinking again, I propose to use
??? ? ? stop(simpleError(msg, call = if(p <- sys.parent()) sys.call(p)))
- It seems that the call is the call of the frame where stopifnot(...) is evaluated. Because that is the correct context, I
2014 Oct 29
2
Unexpected behavior of identical() with language objects
I ran into this and found the result very surprising:
identical( quote({ a }), quote({ a }) )
# FALSE
It seems related to curly braces. For example, parens work fine:
identical( quote(( a )), quote(( a )) )
# TRUE
Is this expected behavior? I can't seem to find anything in the help
for identical that relates to this.
-Winston
2008 Aug 07
1
dput function (PR#12112)
Full_Name: Juan Gea
Version: R version 2.6.2
OS: Fedora Core 6
Submission from: (NULL) (79.153.48.49)
Abort:
objeS <- matrix("AAA",1000000)
class(objeS)
outTxt <- textConnection("vaClob", open = "w", local = FALSE)
dput(objeS,outTxt)
close(outTxt)
R version 2.6.2 (2008-02-08)
Copyright (C) 2008 The R Foundation for Statistical Computing
ISBN
2024 Feb 07
1
[EXTERNAL] Re: NOTE: multiple local function definitions for ?fun? with different formal arguments
I put the idea below into a function that gives nicer looking results.
Here's the new code:
dupnames <- function(path = ".") {
Rfiles <- pkgload:::find_code(path)
allnames <- data.frame(names=character(), filename=character(), line
= numeric())
result <- NULL
for (f in Rfiles) {
exprs <- parse(f, keep.source = TRUE)
locs <-
2020 Apr 11
1
Long model specification causes aov() to abort with error
Dear R developers,
while experimenting with repeated measures ANOVA, I found out that it is
possible to construct a model specification that is syntactically valid,
but causes aov() to abort with an error. A minimal reproducer and its
output are attached to this mail. I was able to reproduce this problem
with the latest SVN revision.
The root cause is similar to that of bug 15377: aov()
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
2023 Jan 11
1
return value of {....}
I am more than a little puzzled by your question.
In the construct {expr1; expr2; expr3} all of the
expressions expr1, expr2, and expr3 are evaluated,
in that order. That's what curly braces are FOR.
When you want some expressions evaluated in a
specific order, that's why and when you use curly
braces. If that's not what you want, don't use them.
Complaining about it is like
2007 Apr 08
1
buglet in terms calculations
Hi,
Vince and I have noticed a problem with non-syntactic names in data
frames and some modeling code (but not all modeling code).
The following, while almost surely as documented could be a bit more
helpful:
m = matrix(rnorm(100), nc=10)
colnames(m) = paste(1:10, letters[1:10], sep="_")
d = data.frame(m, check.names=FALSE)
f = formula(`1_a` ~ ., data=d)
tm =
2012 Feb 21
2
Using substitute in nested function calls
Dear List members,
I really, like the feature that one can call R functions with
mathematical expressions, e.g.
curve(x^2, 0, 1)
I wonder, how I can construct in a simple way a function like
mycurve = function (expr) {...}
such that that a call
mycurve(x^2)
has the same effect as the call
curve(x^2, -100,100)
Below is some code that works, but it seems much to complicated: it
first
2023 Jan 09
5
return value of {....}
Dear members,
I have the following code:
> TB <- {x <- 3;y <- 5}
> TB
[1] 5
It is consistent with the documentation: For {, the result of the last expression evaluated. This has the visibility of the last evaluation.
But both x AND y are created, but the "return value" is y. How can this be advantageous for solving practical problems?
2023 Jan 09
2
return value of {....}
Unless you do something special within a function, only the value(s)
returned are available to the caller. That is the essence of
functional-type programming languages.
You need to read up on (function) environments in R . You can search on
this. ?function and its links also contain useful information, but it may
too terse to be explicable to you. There are of course many available
references on
2019 Aug 16
1
Documenting else's greed
I was initially pretty shocked by the result in this question:
https://stackoverflow.com/questions/57527434/when-do-i-need-parentheses-around-an-if-statement-to-control-the-sequence-of-a-f
Briefly, the following returns 0, not 3 as might be expected:
if (TRUE) {
0
} else {
2
} + 3
At first I thought it the question was simply one of syntax
precedence, but I believe the result is too
2023 Jan 09
1
return value of {....}
I suspect akshay is (or was? Not sure) unclear about what braces do. They are not closures... they create an expression that wraps multiple expressions into one expression... they are a little more like parentheses than closures. They are not intrinsically associated with creation of environments for holding variables.
Functions are closures... they run in a call-specific environment that
2016 Sep 25
3
withAutoprint({ .... }) ?
>>>>> Henrik Bengtsson <henrik.bengtsson at gmail.com>
>>>>> on Sat, 24 Sep 2016 11:31:49 -0700 writes:
> Martin, did you post your code for withAutoprint() anywhere?
> Building withAutoprint() on top of source() definitely makes sense,
> unless, as Bill says, source() itself could provide the same feature.
I was really mainly asking
2003 Nov 05
1
objects inside curly braces
Hello,
I am running a program in r that calls a function, which calls another
function, which calls another etc. These functions are of the form:
example<- function(x,y,z)
{x, y, and z are defined within curly braces like this}
Here's my question. To start the main function, I input as an initial
parameter a matrix of regressors of the form:
MyMatrix<-cbind(this.one,that.one)