Re: [R] understanding as.list(substitute(...()))

2020-10-06 Thread peter dalgaard
> On 6 Oct 2020, at 09:22 , Dénes Tóth wrote: > > > foo <- function(...) substitute({...()}) > > foo(abc$de, fg[h], i) > { > pairlist(abc$de, fg[h], i) > } > > foo(abc$de, fg[h], , i) # add a missing argument for extra fun > { > as.pairlist(alist(abc$de, fg[h], , i)) > } > The 2nd one he

Re: [R] understanding as.list(substitute(...()))

2020-10-06 Thread Tim Taylor
Cheers Denes, That's useful to know. I'll stick with the match.call version instead. Interestingly I initially tried to post to R-devel (as I thought it may involve something internal) but was asked to post here instead. Best Tim On Tue, 6 Oct 2020 at 08:22, Dénes Tóth wrote: > > Hi Tim, >

Re: [R] understanding as.list(substitute(...()))

2020-10-06 Thread Dénes Tóth
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 wou

Re: [R] understanding as.list(substitute(...()))

2020-10-05 Thread Tim Taylor
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. d

Re: [R] understanding as.list(substitute(...()))

2020-10-05 Thread Bert Gunter
You need to understand what substitute() does -- see ?substitute and/or a tutorial on "R computing on the language" or similar. Here is a simple example that may clarify: > dots <- function(...) as.list(substitute(...())) > dots(log(foo)) [[1]] log(foo) ## a call, a language object > dots2 <- f

[R] understanding as.list(substitute(...()))

2020-10-05 Thread Tim Taylor
Could someone explain what is happening with the ...() of the following function: dots <- function(...) as.list(substitute(...())) I understand what I'm getting as a result but not why. ?dots and ?substitute leave me none the wiser. regards Tim __ R