Dear R-users, I am trying to develop a function that takes another function as an argument, changes its default values and returns a list of things, among which the initial function with its default arguments changed. An example of what i will like to obtain below:
## initial function myfun <- function(x, a=19, b=21){ return(a * x + b) } ## this is the function i will like to create ## (does not work as it is written here) mysecond.fun <- function(a, b, c = myfun(a=2, b=15)){ return(list(a=a, b=b c=c)) } So I would be able to call: mysecond.fun$c(x=12) And this will be equivalent of calling: myfun(x=12, a=2, b=15 ) ## i.e. i have changed the default values of myfun and ## stored it in a new function mysecond.fun$c Any help will be greatly appreciated! Miguel Bernal. ---- Current address: Ocean Modeling group, Institute of Marine and Coastal Sciences University of Rutgers 71 Dudley Road, New Brusnkwick, New Jersey 08901, USA email: mber...@marine.rutgers.edu phone: +1 732 932 3692 Fax: +1 732 932 8578 --------------------------------------------- Permanent address: Instituto Español de Oceanografía Centro Oceanográfico de Cádiz Puerto Pesquero, Muelle de Levante, s/n Apdo. 2609, 11006 Cádiz, Spain email: miguel.ber...@cd.ieo.es phone: +34 956 294189 Fax: +34 956 294232 ______________________________________________ R-help@r-project.org mailing list 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.