Displaying 20 results from an estimated 4000 matches similar to: "support of `substitute(...())`"
2018 May 03
7
length of `...`
Hi,
In some cases the number of arguments passed as ... must be determined
inside a function, without evaluating the arguments themselves. I use
the following construct:
dotlength <- function(...) length(substitute(expression(...))) - 1L
# Usage (returns 3):
dotlength(1, 4, something = undefined)
How can I define a method for length() which could be called directly on
`...`? Or is it an
2020 Oct 06
0
understanding as.list(substitute(...()))
Hi Tim,
I have also asked a similar question a couple of months ago, and someone
else did the same recently, maybe on r-devel.
We received no "official" response, but Deepayan Sarkar (R Core Team
member) claimed that:
"
There is no documented reason for this to work (AFAIK), so again, I
would guess this is a side-effect of the implementation, and not a API
feature you should
2020 Oct 06
3
understanding as.list(substitute(...()))
I probably need to be more specific. What confuses me is not the use
of substitute, but the parenthesis after the dots. It clearly works
and I can make guesses as to why but it is definitely not obvious.
The following function gives the same final result but I can
understand what is happening.
dots <- function (...) {
exprs <- substitute(list(...))
as.list(exprs[-1])
}
In the
2020 Nov 20
2
return (x+1) * 1000
And the related:
> f = function() stop(return("lol"))
> f()
[1] "lol"
I have a feeling all of this is just return() performing correctly though.
If there are already R CMD CHECK checks for this kind of thing (I
wasnt sure but I'm hearing from others there may be/are) that may be
(and/or may need to be) sufficient.
~G
On Fri, Nov 20, 2020 at 3:27 PM D?nes T?th
2020 Nov 20
2
return (x+1) * 1000
Without having dug into the details, it could be that one could update
the parser by making a 'return' a keyword and require it to be
followed by a parenthesis that optionally contains an expression
followed by end of statement (newline or semicolon). Such a
"promotion" of the 'return' statement seems backward compatible and
would end up throwing syntax errors on:
2020 Nov 21
1
return (x+1) * 1000
On 20/11/2020 7:01 p.m., Ben Bolker wrote:
> I may be unusual but I don't find these examples surprising at all/
> I don't think I would make these mistakes (maybe it's easier to make
> that mistake if you're used to a language where 'return' is a keyword
> rather than a function?
>
> My two cents would be that it would make more sense to (1) write
2020 Mar 12
0
support of `substitute(...())`
Note that substitute(...()) and substitute(someFunc(...))[-1] give slightly
different results, the former a pairlist and the latter a call.
> str((function(...)substitute(...()))(stop(1),stop(2),stop(3)))
Dotted pair list of 3
$ : language stop(1)
$ : language stop(2)
$ : language stop(3)
>
str((function(...)substitute(someFunc(...))[-1])(stop(1),stop(2),stop(3)))
language
2018 Aug 30
3
ROBUSTNESS: x || y and x && y to give warning/error if length(x) != 1 or length(y) != 1
On 08/30/2018 01:56 PM, Joris Meys wrote:
> I have to agree with Emil here. && and || are short circuited like in C and
> C++. That means that
>
> TRUE || c(TRUE, FALSE)
> FALSE && c(TRUE, FALSE)
>
> cannot give an error because the second part is never evaluated. Throwing a
> warning or error for
>
> c(TRUE, FALSE) || TRUE
>
> would mean
2020 Oct 19
2
Is there any way to check the class of an ALTREP?
Benjamin,
You happened to send a link which points to the OP's own package :) I
think Jiefei would like to know how one can "officially" determine if an
arbitrary ALTERP object belongs to a class that he owns.
Regards,
Denes
On 10/19/20 10:22 AM, Benjamin Christoffersen wrote:
> It seems as if you can you use the ALTREP macro as done in this
> package:
2018 Aug 30
3
ROBUSTNESS: x || y and x && y to give warning/error if length(x) != 1 or length(y) != 1
>>>>> Joris Meys
>>>>> on Thu, 30 Aug 2018 14:48:01 +0200 writes:
> On Thu, Aug 30, 2018 at 2:09 PM D?nes T?th
> <toth.denes at kogentum.hu> wrote:
>> Note that `||` and `&&` have never been symmetric:
>>
>> TRUE || stop() # returns TRUE stop() || TRUE # returns an
>> error
>>
2020 May 01
4
Request: tools::md5sum should accept connections and finally in-memory objects
AFAIK there is no hashing utility in base R which can create hash
digests of arbitrary R objects. However, as also described by Henrik
Bengtsson in [1], we have tools::md5sum() which calculates MD5 hashes of
files. Calculating hashes of in-memory objects is a very common task in
several areas, as demonstrated by the popularity of the 'digest' package
(~850.000 downloads/month).
Upon
2018 May 03
1
Converting a list to a data frame
This is very nice to learn about, Denis, but it seems only fair to point out that the result of rbindlist is not a data frame. You can convert it to a data frame easily, but the copy and indexing semantics of data tables are quite different than data tables, which could be a real headache for someone not prepared for those differences. (To learn more, read the data tables vignette.)
Tibbles (as
2020 Oct 19
1
Is there any way to check the class of an ALTREP?
Thank Denes for the clarification, glad to see my package got one citation
from my own question:) Also, thank Benjamin
for sending many useful documents.
Actually, the question is related to the SharedObject package that Benjamin
has pointed to. I wanna
avoid sharing an object that has already been shared, so I need to check
whether an object is an ALTREP
that is defined in my package. Since the
2017 Dec 11
1
possible bug in utils::removeSource - NULL argument is silently dropped
Dear R-Core Team,
I found an unexpected behaviour in utils::removeSource (also present in
r-devel as of today).
---
# create a function which accepts NULL argument
foo <- function(x, y) {
if (is.null(y)) y <- "default foo"
attr(x, "foo") <- y
x
}
# create a function which utilizes 'foo'
testSrc <- function() {
x <- 1:3
x <- foo(x,
2018 May 02
0
Converting a list to a data frame
On 05/02/2018 07:11 PM, Kevin E. Thorpe wrote:
> I suspect this is pretty easy, but I'm having trouble figuring it out.
> Basically, I have a list of data frames such as the following example:
>
> list(A=data.frame(x=1:2, y=3:4),B=data.frame(x=5:6,y=7:8))
>
> I would like to turn this into data frame where the list elements are
> essentially rbind'ed together and
2017 Sep 28
2
Searching for Enumerated Items using str_count() from the stringr package
Hi all,
I have a large number of text strings to search for enumerated items.
However, I am receiving this error message even though I thought that I
properly escaped the special character closed parenthesis:
> Count<-str_count(text3,keywords)
Error in stri_count_regex(string, pattern, opts_regex = opts(pattern)) :
Syntax error in regexp pattern. (U_REGEX_RULE_SYNTAX)
===
Here is
2017 Sep 28
0
Searching for Enumerated Items using str_count() from the stringr package
On 09/28/2017 10:25 PM, Dan Abner wrote:
> Hi all,
>
> I have a large number of text strings to search for enumerated items.
> However, I am receiving this error message even though I thought that I
> properly escaped the special character closed parenthesis:
>
>
>> Count<-str_count(text3,keywords)
> Error in stri_count_regex(string, pattern, opts_regex =
2024 Jun 28
1
Positron as a tool
Just to be clear, Denis, I am not in any way associated with anybody or anything and just read about it on a news feed not from POSIT directly.
I am aware it is based on existing functionality and have used possibly similar editors for other languages. I did try possibly one touted by Microsoft years ago (perhaps what you are referring to) but felt no need to keep using it at the time. What I am
2018 Apr 27
0
Package 'data.table' in version R-3.5.0 not successfully being installed
Hmm, looks like that thread has more noise than signal...
AFAICT, data.table currently fails selftests i 3.5.0 on all platforms on the CRAN builders, so RTools issues are only incidental and it would be better to fix data.table in the sources.
From the looks of it, I wouldn't be surprised if the root cause is the changes to POSIXlt methods in 3.5.0, but I haven't actually been digging
2018 Apr 26
2
Package 'data.table' in version R-3.5.0 not successfully being installed
You might find this discussion useful, too:
https://github.com/Rdatatable/data.table/issues/2797
On 04/26/2018 11:01 PM, Henrik Bengtsson wrote:
> If you're installing packages to the default location in your home
> account and you didn't remove those library folders, you still have
> you R 3.4 package installs there, e.g.
>
>> dir(dirname(.libPaths()[1]), full.names =