[R] Getting *types* of arguments?

Prof Brian Ripley ripley at stats.ox.ac.uk
Thu Feb 17 13:34:26 CET 2005

On Thu, 17 Feb 2005, Georg Hoermann wrote:

> Hello world,
> short question: is there a possibility to get a list of
> arguments of a function *with* variable/parameter types?

Do you mean `argument' or `formal argument' or `parameter' or `variable'?

> formals() gives me the names of the parameters, but says
> nothing about the parameter type it expects (I know I can always use the
> help function).
> I would like somthing like
> $x: vector or data.frame...

No, because R's argument matching is polymorphic and many functions have 
arguments that accept many types, or coerce arguments to the required 

BTW, a data frame is a list which is a vector, so your example isn't very 
realistic and shows that `type' is not a concept you have clear.  R has 
modes (?mode), types (?typeof) and classes (?class).  Neither `vector' nor 
`data frame' is a type.

Brian D. Ripley,                  ripley at 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 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

More information about the R-help mailing list