Re: [Rd] change function's formals default values

From: Andrew Finley <afinley_at_stat.umn.edu>
Date: Tue 04 Apr 2006 - 14:42:30 GMT

Hi Thomas,

Thanks for the note. I'm not sure about a lot of things. Setting the formal defaults then calling the function seem straight forward. I just assumed it would be like setting list values, or the C equivalent of calling formals(fn)<-list(a=1, b=3).

Following your suggestion, I can get the names of the parameters used in this user defined function, but am not sure how to do what you are suggesting. For instance, how do I call the function after I use setVar. Could you point me to an example?

Thanks again!

Andrew

On Tue, 2006-04-04 at 07:21 -0700, Thomas Lumley wrote:
> On Mon, 3 Apr 2006, Andrew Finley wrote:
>
> > Hello,
> >
> > I'm passing a user defined function into my c code. Once this function
> > is in my c code, I'd like to iteratively change the values associated
> > with the parameters defined in the function's formal list then evaluate
> > the function using these newly set defaults (i.e., using lang1(fn)).
> >
> > My question is, how do I simply change the value associated with each
> > parameter in this function's formal list. I have messed around with the
> > SET_FORMAL function but can't figure out how to change these values.
> >
>
> <recoils in horror>
>
> Are you *sure* you want to do this? It seems that you should be able to
> use lexical scope to store this information in variables rather than
> default arguments and then you can use setVar to change the variables
> rather than changing the formals.
>
> -thomas
>
> Thomas Lumley Assoc. Professor, Biostatistics
> tlumley@u.washington.edu University of Washington, Seattle
>
> ______________________________________________
> R-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel

-- 
Research Fellow
Department of Forest Resources
University of Minnesota
Office: 305 Green Hall
Phone: (612) 624-1714
Fax: (612) 625-5212
web: http://blue.fr.umn.edu

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Received on Wed Apr 05 01:24:47 2006

This archive was generated by hypermail 2.1.8 : Tue 04 Apr 2006 - 20:16:53 GMT