[R] print (names and) values of parameters of function

David Winsemius dwinsemius at comcast.net
Sun Oct 9 05:07:43 CEST 2016


> On Oct 8, 2016, at 7:21 AM, Christian Hoffmann <christian at echoffmann.ch> wrote:
> 
> I try to print  (names and) values of parameters of a function within that function, like:
> 
> F <- function(x, y, z=4, ...) {
> 
> print("x = ", x, " , y = ",  y, "... = " , ...)
> 
> in a fashion that avoids the explicit mention of "x = ", x, " , y = ",  y, "... = " , ...
> 
> Combinations of eval, substitute, formals, etc. should be able to do the job, but I didn't find help online.

Try this:

 F <- function(x, y, z=4, ...) {this_call <- sys.call()
                                print(this_call) }
 F(x=2,y=3,z=5)
# F(x = 2, y = 3, z = 5)

> 
> Anyone lend a helping hand?
> TIA  Christian
> 
> -- 
> Christian W. Hoffmann
> CH - 8915 Hausen am Albis, Schweiz
> Rigiblickstrasse 15 b, Tel.+41-44-7640853
> mailto: christian at echoffmann.ch
> home: www.echoffmann.ch
> 
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

David Winsemius
Alameda, CA, USA



More information about the R-help mailing list