[R] formals or args question

Dimitris Rizopoulos dimitris.rizopoulos at med.kuleuven.ac.be
Mon May 23 16:58:24 CEST 2005


formals() returns a list, so you could try this:

a <- function(p, r) p + r
names(formals(a))


I hope it helps.

Best,
Dimitris

----
Dimitris Rizopoulos
Ph.D. Student
Biostatistical Centre
School of Public Health
Catholic University of Leuven

Address: Kapucijnenvoer 35, Leuven, Belgium
Tel: +32/16/336899
Fax: +32/16/337015
Web: http://www.med.kuleuven.ac.be/biostat/
     http://www.student.kuleuven.ac.be/~m0390867/dimitris.htm


----- Original Message ----- 
From: "BJ" <erithid at bellsouth.net>
To: <r-help at stat.math.ethz.ch>
Sent: Monday, May 23, 2005 4:45 PM
Subject: [R] formals or args question


> Hello again, thank you again for all of your help. I am trying to 
> get the arguments for a function, in a way that I can handle them. 
> If I do args(fun), it doesnt really do what I want. If I use 
> formals(fun) i get output like:
>
> $a
>
>
> $r
>
>
> $s
>
>
> Now, lthis is supposedly a list, but if i say formals(a)[[1]], I get 
> nothing. I am just trying to get a vector with teh arguments  of a 
> function so I can loop over them.
>
> ex; a<-function(p,r){p+r}
>
> want: vector of c("p", "r")
>
> The documentation for args and formals is quite confusing. Thanks 
> again! ~Erithid
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! 
> http://www.R-project.org/posting-guide.html
>




More information about the R-help mailing list