Hello list,
I have a question concerning argument matching I have read R Language Definition before).
I have a function multxby2 which takes as argument the call to another function f1.
I would like to take the values of xx from the call to f1 and use it in multxby2.


Here is an example:


multxby2 <- function(callf) { appel1<-match.call() appel<-as.list(as.call(appel1$callf))

    px<-pmatch(names(appel),"xx")

    if(sum(is.na(px))!=length(appel)) print(appel[[which(!is.na(px))]]*2)
    # else ...

}

f1=function(xx=2,y=3){}

multxby2(f1(x=3))

My problem is due to the various ways that a user can enter its arguments, how to be sure to get xx from various call such as:

multxby2(f1(3,2))
multxby2(f1(y=2,3))

Is there a way to do that avoiding a lot of "if" and how to solve the last case ? My practical case takes functions with around 20 arguments.

Thanks in advance,

Sincerely.
St�phane DRAY
--------------------------------------------------------------------------------------------------


D�partement des Sciences Biologiques
Universit� de Montr�al, C.P. 6128, succursale centre-ville
Montr�al, Qu�bec H3C 3J7, Canada

Tel : (514) 343-6111 poste 1233 Fax : (514) 343-2293
E-mail : [EMAIL PROTECTED]
--------------------------------------------------------------------------------------------------


Web                                          http://www.steph280.freesurf.fr/

______________________________________________
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to