From becker@g@be @ending from gene@com  Thu May  3 17:00:02 2018
From: becker@g@be @ending from gene@com (Gabe Becker)
Date: Thu, 3 May 2018 08:00:02 -0700
Subject: [Rd] length of `...`
In-Reply-To: <CAOKDuOjM0HZ+-e++P7J951DpWk4yn1uPO+e+j_N-xLHJmL_Oaw@mail.gmail.com>
References: <d0b68216-4922-2249-e5e6-1589345dc6d7@kogentum.hu>
 <CAOKDuOjM0HZ+-e++P7J951DpWk4yn1uPO+e+j_N-xLHJmL_Oaw@mail.gmail.com>
Message-ID: <CAMFmJs=+skVenVSFMbQvSDCZofzpESgrvStpOns5m8Ov8tD40g@mail.gmail.com>

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, Mark van der Loo <mark.vanderloo at gmail.com>
wrote:

> 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.call(someotherfunction, L)
>
> }
>
>
> -Mark
>
> Op do 3 mei 2018 om 16:29 schreef D?nes T?th <toth.denes at kogentum.hu>:
>
> > 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 intention to extend the base length() function to
> > accept ellipses?
> >
> >
> > Regards,
> > Denes
> >
> > ______________________________________________
> > R-devel at r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-devel
> >
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>



-- 
Gabriel Becker, Ph.D
Scientist
Bioinformatics and Computational Biology
Genentech Research

	[[alternative HTML version deleted]]




[Rd] length of `...`
Gabe Becker