From ripley@stats.ox.ac.uk  Tue Jul 25 12:22:48 2000
From: ripley@stats.ox.ac.uk (Prof Brian D Ripley)
Date: Tue, 25 Jul 2000 12:22:48 +0100 (BST)
Subject: [Rd] number of parameters of a function.
In-Reply-To: <200007251112.HAA06228@jessie.research.bell-labs.com>
Message-ID: <Pine.GSO.4.05.10007251220330.7029-100000@auk.stats>

On Tue, 25 Jul 2000, Duncan Temple Lang wrote:

> 
>  Is there a way to programmatically determine how many arguments a function
> accepts? In S, one can compute this as 
>           length(theFunction) - 1
> and determine the parameter names  as
>           names(theFunction)
> due to the representation of functions.

length(formals(theFunction))

Something similar works in S-PLUS 5.x:

length(functionArgs(theFunction))

as I guess Duncan knows.

-- 
Brian D. Ripley,                  ripley@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


[Rd] number of parameters of a function.
Prof Brian D Ripley