[R] generically setting attributes of a function

From: shang stud <facS93_at_mors.hampshire.edu>
Date: Wed 09 Mar 2005 - 09:00:53 EST

Hello all:

I wonder if there is a generic way to assign the name of a function as an attribute of the function. For example,

w = function(x) x^2;
attr(w, "name") = "w";

This assigns the name attribute of function w to be "w".

Would it be possible to put the second line of the code inside the function definition? I would like to avoid typing specifically the name, "w", when assigning the attribute.

Many thanks in advance.

Fang



R-help@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 Received on Wed Mar 09 09:07:43 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:30:41 EST