Re: [Rd] length of `...`

2018-05-08 Thread Hervé Pagès
Thanks Martin for the clarifications. H. On 05/04/2018 06:02 AM, Martin Maechler wrote: Hervé Pagès on Thu, 3 May 2018 08:55:20 -0700 writes: > Hi, > It would be great if one of the experts could comment on the > difference between Hadley's dotlength and ...length? The fa

Re: [Rd] length of `...`

2018-05-06 Thread Suharto Anggono Suharto Anggono via R-devel
Does anyone notice r-devel thread "stopifnot() does not stop at first non-TRUE argument" starting with https://stat.ethz.ch/pipermail/r-devel/2017-May/074179.html ? I have mentioned (function(...)nargs())(...) in https://stat.ethz.ch/pipermail/r-devel/2017-May/074294.html . Something like ..elt

Re: [Rd] length of `...`

2018-05-04 Thread Martin Maechler
> Joris Meys > on Fri, 4 May 2018 15:37:27 +0200 writes: > The one difference I see, is the necessity to pass the dots to the function > dotlength : > dotlength <- function(...) nargs() > myfun <- function(..., someArg = 1){ > n1 <- ...length() > n2 <- dotle

Re: [Rd] length of `...`

2018-05-04 Thread Joris Meys
The one difference I see, is the necessity to pass the dots to the function dotlength : dotlength <- function(...) nargs() myfun <- function(..., someArg = 1){ n1 <- ...length() n2 <- dotlength() n3 <- dotlength(...) return(c(n1, n2, n3)) } myfun(stop("A"), stop("B"), someArg = stop("c")

Re: [Rd] length of `...`

2018-05-04 Thread Martin Maechler
> Hervé Pagès > on Thu, 3 May 2018 08:55:20 -0700 writes: > Hi, > It would be great if one of the experts could comment on the > difference between Hadley's dotlength and ...length? The fact > that someone bothered to implement a new primitive for that > when there

Re: [Rd] length of `...`

2018-05-03 Thread Michel Lang
FWIW, there is also a backport of `...length()` for R versions >3.0.0 in my package backports (shameless self promotion): . 2018-05-03 19:41 GMT+02:00 peter dalgaard : > > >> On 3 May 2018, at 19:23 , Hadley Wickham wrote: >> >> Maybe just get(paste0("..", n))

Re: [Rd] length of `...`

2018-05-03 Thread peter dalgaard
> On 3 May 2018, at 19:23 , Hadley Wickham wrote: > > Maybe just get(paste0("..", n)) ? > > Hadley Maybe not. These things are slippery. > f <- function(...) get("..1") > f(2) Error in get("..1") : object '..1' not found -- Peter Dalgaard, Professor, Center for Statistics, Copenhagen Busin

Re: [Rd] length of `...`

2018-05-03 Thread Hadley Wickham
On Thu, May 3, 2018 at 9:50 AM, Duncan Murdoch wrote: > On 03/05/2018 11:18 AM, Duncan Murdoch wrote: >> >> On 03/05/2018 11:01 AM, William Dunlap via R-devel wrote: >>> >>> In R-3.5.0 you can use ...length(): >>> > f <- function(..., n) ...length() >>> > f(stop("one"), stop("two"), stop("

Re: [Rd] length of `...`

2018-05-03 Thread Duncan Murdoch
On 03/05/2018 11:18 AM, Duncan Murdoch wrote: On 03/05/2018 11:01 AM, William Dunlap via R-devel wrote: In R-3.5.0 you can use ...length(): > f <- function(..., n) ...length() > f(stop("one"), stop("two"), stop("three"), n=7) [1] 3 Prior to that substitute() is the way to go > g

Re: [Rd] length of `...`

2018-05-03 Thread Hervé Pagès
Hi, It would be great if one of the experts could comment on the difference between Hadley's dotlength and ...length? The fact that someone bothered to implement a new primitive for that when there seems to be a very simple and straightforward R-only solution suggests that there might be some got

Re: [Rd] length of `...`

2018-05-03 Thread Hadley Wickham
On Thu, May 3, 2018 at 8:28 AM, Hadley Wickham wrote: > On Thu, May 3, 2018 at 8:00 AM, Gabe Becker wrote: >> As of 3.5.0 the ...length() function does exactly what you are asking for. >> Before that, I don't know of an easy way to get the length without >> evaluation via R code. There may be one

Re: [Rd] length of `...`

2018-05-03 Thread Hadley Wickham
On Thu, May 3, 2018 at 8:18 AM, Duncan Murdoch wrote: > On 03/05/2018 11:01 AM, William Dunlap via R-devel wrote: >> >> In R-3.5.0 you can use ...length(): >>> f <- function(..., n) ...length() >>> f(stop("one"), stop("two"), stop("three"), n=7) >>[1] 3 >> >> Prior to that substitute()

Re: [Rd] length of `...`

2018-05-03 Thread Hadley Wickham
On Thu, May 3, 2018 at 8:00 AM, Gabe Becker wrote: > As of 3.5.0 the ...length() function does exactly what you are asking for. > Before that, I don't know of an easy way to get the length without > evaluation via R code. There may be one I'm not thinking of though, I > haven't needed to do this m

Re: [Rd] length of `...`

2018-05-03 Thread Martin Morgan
nargs() provides the number of arguments without evaluating them > f = function(x, ..., y) nargs() > f() [1] 0 > f(a=1, b=2) [1] 2 > f(1, a=1, b=2) [1] 3 > f(x=1, a=1, b=2) [1] 3 > f(stop()) [1] 1 On 05/03/2018 11:01 AM, William Dunlap via R-devel wrote: In R-3.5.0 you can use ...length():

Re: [Rd] length of `...`

2018-05-03 Thread peter dalgaard
> On 3 May 2018, at 16:52 , Mark van der Loo wrote: > > This question is better aimed at the r-help mailinglist as it is not about > developing R itself. Um, no... People there might well send you back here. As for the original question, there are also variations over dddlen <- function(...)

Re: [Rd] length of `...`

2018-05-03 Thread Duncan Murdoch
On 03/05/2018 11:01 AM, William Dunlap via R-devel wrote: In R-3.5.0 you can use ...length(): > f <- function(..., n) ...length() > f(stop("one"), stop("two"), stop("three"), n=7) [1] 3 Prior to that substitute() is the way to go > g <- function(..., n) length(substitute(...())) >

Re: [Rd] length of `...`

2018-05-03 Thread Tóth Dénes
Thank you Bill (and the R-Core Team), this is even more than what I thought of. I somehow missed this in the NEWS. BTW, substitue(...()) is beautiful. On 05/03/2018 05:01 PM, William Dunlap wrote: In R-3.5.0 you can use ...length(): > f <- function(..., n) ...length() > f(stop("one"), s

Re: [Rd] length of `...`

2018-05-03 Thread Gabe Becker
As of 3.5.0 the ...length() function does exactly what you are asking for. Before that, I don't know of an easy way to get the length without evaluation via R code. There may be one I'm not thinking of though, I haven't needed to do this myself. Hope that helps. ~G On Thu, May 3, 2018 at 7:52 AM

Re: [Rd] length of `...`

2018-05-03 Thread William Dunlap via R-devel
In R-3.5.0 you can use ...length(): > f <- function(..., n) ...length() > f(stop("one"), stop("two"), stop("three"), n=7) [1] 3 Prior to that substitute() is the way to go > g <- function(..., n) length(substitute(...())) > g(stop("one"), stop("two"), stop("three"), n=7) [1] 3 R-3.5.0

Re: [Rd] length of `...`

2018-05-03 Thread Mark van der Loo
This question is better aimed at the r-help mailinglist as it is not about developing R itself. having said that, I can only gues why you want to do this, but why not do something like this: f <- function(...){ L <- list(...) len <- length() # you can stll pass the ... as follows: do

[Rd] length of `...`

2018-05-03 Thread Dénes Tóth
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 = unde

Re: [Rd] Length of seed for l'Ecuyer-CMRG

2013-01-22 Thread Marius Hofert
I'm sorry, I must have overlooked the "... as given by .Random.seed". Thanks for helping. Marius __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel

Re: [Rd] Length of seed for l'Ecuyer-CMRG

2013-01-22 Thread Prof Brian Ripley
On 22/01/2013 23:22, Marius Hofert wrote: Dear expeRts, ./src/library/base/man/Random.Rd says that L'Ecuyer requires a seed of length 6. ./src/library/parallel/man/RngStream.Rd also mentions this, but only in the text part; In the "Arguments"-part, it says that "seed" has to be of length 7 Als

[Rd] Length of seed for l'Ecuyer-CMRG

2013-01-22 Thread Marius Hofert
Dear expeRts, ./src/library/base/man/Random.Rd says that L'Ecuyer requires a seed of length 6. ./src/library/parallel/man/RngStream.Rd also mentions this, but only in the text part; In the "Arguments"-part, it says that "seed" has to be of length 7 Also: , | > RNGkind("L'Ecuyer-CMRG") | > l

Re: [Rd] length of POSIXlt object (PR#13482)

2009-01-30 Thread Patrick Burns
'The R Inferno' page 93 and page 99. Patrick Burns patr...@burns-stat.com +44 (0)20 8525 0696 http://www.burns-stat.com (home of "The R Inferno" and "A Guide for the Unwilling S User") twoutop...@gmail.com wrote: The length() of a POSIXlt object is given as 9 regardless of the actual length. F

Re: [Rd] length of POSIXlt object (PR#13482)

2009-01-29 Thread Jeff Ryan
Read the docs. POSIXlt is a list of 9 elements. Each element length is what you think it should be returning. That is not correct. ?POSIXlt Details: There are two basic classes of date/times. Class '"POSIXct"' represents the (signed) number of seconds since the beginning of 1970

[Rd] length of POSIXlt object (PR#13482)

2009-01-29 Thread twoutopias
The length() of a POSIXlt object is given as 9 regardless of the actual length. For example: > make.date.time function (year=c(2006,2006),month=c(8,8),day=2:5,hour=13,minute=45) {# convert year, etc., into POSIXlt object # d=as.character(make.date(year,month,day)) t=paste(hour,minute,sep=":") as.P